Mail forwarded/replied to icons in Outlook

D

Dan

Hi

I have written a Macro that automatically BCCs a copy of all my incoming
mail and sent mail to a particular address for backup. When it does this it
marks the mail as forwarded in my inbox. How can i stop this in the macro as
it is clearly confusing to have all my incoming mail marked as forwarded.

this is part of the code for inbox forwarding:

Private Sub myOlItems_ItemAdd(ByVal Item As Object)

If TypeName(Item) = "MailItem" Then
' Forward the item just received
Set myForward = Item.Forward

' Address the message
Set myBCC = myForward.Recipients.Add("xxx")
myBCC.Type = olBCC

'Don't save another copy
myForward.DeleteAfterSubmit = True
' Send it
myForward.Send


End If



End Sub
 
G

Guest

Instead of forwarding the items, create new messages. Then use the object
reference you have from the ItemAdd event that points to the e-mail that you
want to forward as an argument for the Attachment.Add method:

Set myNewMessage = Application.CreateItem(olMailItem)
myNewMessage.Attachments.Add Item, OlAttachmentType.olByValue

etc.
 
D

Dan

Thanks. That works. The only problem is that all the messages are coming
through with no subject. Is it not possible to create a copy of the received
email and send that?
 
G

Guest

Hi there this is more or less what I want to do... I want to send a copy of
all mail sent and recieved to another address as bcc... could you please show
me the code as I am fairly new to this... thanks !!!
 
G

Guest

You can use something like this macro. It will forward all selected messages
to the addresses specified in the To and Bcc lines:

Sub ForwardSelectedMessages()
On Error Resume Next

Dim objItem As Object
Dim objForward As Outlook.MailItem

For Each objItem In ActiveExplorer.Selection
If objItem.Class = olMail Then
Set objForward = objItem.Forward
objForward.To = "(e-mail address removed)"
objForward.BCC = "(e-mail address removed)"
objForward.Display
'uncomment to send automatically (comment out objForward.Display
too)
'objForward.Send
Set objItem = Nothing
Set objForward = Nothing
End If
Next

Set objItem = Nothing
Set objForward = Nothing
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
G

Guest

thanks for that but what I was wanting was something that didnt forward the
mails but that sent a new message, then deleted it out sent items, otherwise
same prob all messages say forward ??? doh ! I would like them to remain
unread if possible ?

you said to the original guy, set new message or something ? have you got
the complete code to be able to do that ???

appreciate your reply !!! thanks...
 
G

Guest

Try this then:

Sub ForwardSelectedMessagesAsAttachmentsInNewReplyMessage()
On Error Resume Next

Dim objItem As Object
Dim objReply As Outlook.MailItem

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

For Each objItem In ActiveExplorer.Selection
If objItem.Class = olMail Then
objReply.Attachments.Add objItem
End If
Next

objReply.DeleteAfterSubmit = True
objReply.Display
'uncomment to send automatically (comment out objReply.Display too)
'objReply.Send

Set objItem = Nothing
Set objReply = Nothing
End Sub

This is my last example! If you need changes, consult the documentation -
that's your homework. If you have specific questions I will answer them
though.

Also check out this site for more programming resources:

Visual Basic and VBA Coding in Microsoft Outlook:
http://www.outlookcode.com/d/vb.htm
 
G

Guest

Eric... Thank you loads this is great...

I been messing about with this a little over the weekend because the code
you supplied forwarded the selected message in the inbox rather than the new
mail coming in... I came up with the following.

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

in replace of

For Each objItem In ActiveExplorer.Selection
If objItem.Class = olMail Then
objReply.Attachments.Add objItem
End If
Next

This seems to work (not that I understand it !!! doh)

anyway the only problem I am having is that its showing the new mail as read
after it sends the new message... I have tried to resolve this myself but
cannot figure out how to make the new mail unread after its send the message
to the additional address ???

if you could help me on this last matter I would be so grateful !!!

Thank you loads !!!
 
G

Guest

Its ok I done it !!! Woo Hoo !!! got the code right (kind of) a while back
but was putting it in wrong place etc !!!

item.unread = true !!!

Weah hey !!!

Thanks Loads for you help Eric !!!
 
G

Guest

Set the UnRead property for the MailItem to True. When in doubt, consult the
Outlook VBA documentation or the Object Browser to see what you can work with.
 

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