Outlook VBA forward mail code - worked in Outlook 2007, but won't work in Outlook 2010
The code below forwards all my Outlook mails til my gmail account. It worked perfectly with Outlook 2007. Recently, my work computer was upgraded to Outlook 2010. Now the mails are not forwarded, nothing happens. I have activated macros in the settings, I receive no error messages.
Any tips on what might be the issue?
The code in "This Outlook Session" module:
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryID As Variant
Dim objForwardedItem As MailItem
Dim objOriginalItem As MailItem
Dim newMail As MailItem
On Error Resume Next
For Each varEntryID In Split(EntryIDCollection, ",")
'denne under lagt til
Set objOriginalItem = Application.GetNamespace("MAPI").GetItemFromID(var EntryID) 'det er denne som henter originalsender adresse....ser det ut til...
Set newMail = CreateItem(olMailItem)
With newMail
.To = "MYMAIL@gmail.com"
.Attachments.Add objOriginalItem
.Subject = "" & objOriginalItem.SenderName & ": " & objOriginalItem.Subject '" EE" 'få inn originalavsender i subject
.Display
.Send
End With
Next
End Sub
|