P
Peter Marchert
Hello,
I try to reference a message which is attached to an e-mail. I use the
following code to save the attachment first and then set a reference
to it:
Sub test()
Dim objReply As Outlook.MailItem
Dim objItem As Outlook.MailItem
Set objReply = Outlook.ActiveExplorer.Selection(1)
Call objReply.Attachments.Item(1).SaveAsFile("C:\test1.msg")
' open "C:\test1.msg" via windows explorer -> body is ok
Set objItem = Outlook.CreateItemFromTemplate("C:\test1.msg")
Debug.Print objItem.Body ' -> body is ok
Call objItem.SaveAs("C:\test2.msg", olMSG)
' open "C:\test2.msg" via windows explorer in 2002 -> body is
blank
' open "C:\test2.msg" via windows explorer in 2003/2007 -> body is
ok, but no PR_BODY property exists
Set objItem = Nothing
Set objReply = Nothing
End Sub
As you can see in the comments the body disappears when opening the
saved msg file in 2002.
If I use RDO the message is completely empty (e. g. subject):
Sub test2()
Dim objRDOMail As Object
Dim objRDOAtt As Object
Dim objRDOSession As Object
Set objRDOSession = CreateObject("Redemption.RDOSession")
objRDOSession.MAPIOBJECT = Outlook.Session.MAPIOBJECT
Set objReply = Outlook.ActiveExplorer.Selection(1)
Call objReply.Attachments.Item(1).SaveAsFile("C:\test1.msg")
Set objRDOMail = objRDOSession.CreateMessageFromMsgFile("C:
\test1.msg")
objRDOMail.SaveAs "C:\test2.msg"
' open "C:\test2.msg" via windows explorer in 2002 -> message is
blank
End Sub
I want to ask if there is a workarround or a simplier way to get the
reference to an attached message.
Thanks
Peter
I try to reference a message which is attached to an e-mail. I use the
following code to save the attachment first and then set a reference
to it:
Sub test()
Dim objReply As Outlook.MailItem
Dim objItem As Outlook.MailItem
Set objReply = Outlook.ActiveExplorer.Selection(1)
Call objReply.Attachments.Item(1).SaveAsFile("C:\test1.msg")
' open "C:\test1.msg" via windows explorer -> body is ok
Set objItem = Outlook.CreateItemFromTemplate("C:\test1.msg")
Debug.Print objItem.Body ' -> body is ok
Call objItem.SaveAs("C:\test2.msg", olMSG)
' open "C:\test2.msg" via windows explorer in 2002 -> body is
blank
' open "C:\test2.msg" via windows explorer in 2003/2007 -> body is
ok, but no PR_BODY property exists
Set objItem = Nothing
Set objReply = Nothing
End Sub
As you can see in the comments the body disappears when opening the
saved msg file in 2002.
If I use RDO the message is completely empty (e. g. subject):
Sub test2()
Dim objRDOMail As Object
Dim objRDOAtt As Object
Dim objRDOSession As Object
Set objRDOSession = CreateObject("Redemption.RDOSession")
objRDOSession.MAPIOBJECT = Outlook.Session.MAPIOBJECT
Set objReply = Outlook.ActiveExplorer.Selection(1)
Call objReply.Attachments.Item(1).SaveAsFile("C:\test1.msg")
Set objRDOMail = objRDOSession.CreateMessageFromMsgFile("C:
\test1.msg")
objRDOMail.SaveAs "C:\test2.msg"
' open "C:\test2.msg" via windows explorer in 2002 -> message is
blank
End Sub
I want to ask if there is a workarround or a simplier way to get the
reference to an attached message.
Thanks
Peter