badatvba
2009-06-22 13:37:02 UTC
Hi,
I am using the below code (thanks to Ken Slovak!!) to redirect mail from my
OL email to my googlemail account. It works fine except for mail items which
have been replied to or forwarded - I get the message & subject but the body
is empty.
Is there a different attribute name for the body for forwarded/replied OL
mails?
many thanks
----------------------------------------------------------------------------------
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
MsgBox "Running Application_Startup"
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
'Extract info from the mailItem
Set myItem = Application.CreateItem(olMailItem)
Dim oRecip As Outlook.Recipient
Set oRecip = myItem.Recipients.Add("***@googlemail.com")
oRecip.Resolve
'mybody = Item.body
myItem.body = mybody
myItem.Subject = Item.Subject
myItem.Send
End If
End Sub
I am using the below code (thanks to Ken Slovak!!) to redirect mail from my
OL email to my googlemail account. It works fine except for mail items which
have been replied to or forwarded - I get the message & subject but the body
is empty.
Is there a different attribute name for the body for forwarded/replied OL
mails?
many thanks
----------------------------------------------------------------------------------
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
MsgBox "Running Application_Startup"
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
'Extract info from the mailItem
Set myItem = Application.CreateItem(olMailItem)
Dim oRecip As Outlook.Recipient
Set oRecip = myItem.Recipients.Add("***@googlemail.com")
oRecip.Resolve
'mybody = Item.body
myItem.body = mybody
myItem.Subject = Item.Subject
myItem.Send
End If
End Sub