Body disappears in 2002 when creating an item from a saves msgattachment

  • Thread starter Thread starter Peter Marchert
  • Start date Start date
Status
Not open for further replies.
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
 
Re: Body disappears in 2002 when creating an item from a saves msg attachment

Hi Peter,

with RDO object you can directly open the attachment, you don't need to save

it as a file. Does that workaround the empty body?

Best regards

Michael Bauer

Am Fri, 30 Oct 2009 04:09:04 -0700 (PDT) schrieb 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
 
On 3 Nov., 21:21, "Michael Bauer " <m...@mvps.org
wrote:

Hello Michael,

thanks for your reply.

I'm not sure. I tested a lot the last days but finally I have no

solution (the users of 2002 gets a message to do something by hand).

The code is not easy and at least I think with RDO the body was ok,

but I cannot send the message without error (I replace attachments in

the attached message with OOM after the send event had fired).

May be I try something at a later time with RDO, but it seems to me I

have to rewrite great parts of the code to implement this.

Thanks

Peter


> Hi Peter,

> with RDO object you can directly open the attachment, you don't need to save
> it as a file. Does that workaround the empty body?

> > Best regards
> Michael Bauer

> > >

> Am Fri, 30 Oct 2009 04:09:04 -0700 (PDT) schrieb 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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
kburrows Outlook Email Body Text Disappears/Overlaps, Folders Switch Around when You Hover, Excel Opens Randomly and Runs in the Background - Profile Corrupt? Using Outlook 0
D Body text of email disappears when I scan an attachment from printer to email Using Outlook 1
M Outlook 365 adding standard message in body of template email Outlook VBA and Custom Forms 3
B 10 Practical Tips for Healthy and Sustainable Weight Loss10 Steps to Achieving Your Dream Body Outlook VBA and Custom Forms 0
G Retaining Tabs in outlook body Using Outlook 2
S Create Outlook Task from Template and append Body with Email Body Outlook VBA and Custom Forms 4
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
G Creating Macro to scrape emails from calendar invite body Outlook VBA and Custom Forms 6
H Copying email address(es) in body of email and pasting in To field Outlook VBA and Custom Forms 1
D Delete selected text in outgoing email body Outlook VBA and Custom Forms 0
K Incorporate selection from combobox into body of email Outlook VBA and Custom Forms 0
C Populate form data into message body Outlook VBA and Custom Forms 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
Witzker Set Cursor & Focus from any field to the body of a user Contact form in OL 2019 Outlook VBA and Custom Forms 1
J Outlook 2019 Regex email addresses from body Outlook VBA and Custom Forms 6
T 1:1 Datatransfer from incoming mail body to customs form body Outlook VBA and Custom Forms 0
D Copy Appointment Body to Task Body Outlook VBA and Custom Forms 0
Beeto Replace a string in body Outlook VBA and Custom Forms 2
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
Z Copy specific email body text Outlook VBA and Custom Forms 0
J How do you disable address search box when typing @ in body of email? Using Outlook 0
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
M Autoforward just attachment OR just body. Outlook VBA and Custom Forms 0
G Place jpg in body of email Outlook VBA and Custom Forms 1
D Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
J Implement Keywords based on body message Outlook VBA and Custom Forms 0
D auto forward base on email address in body email Outlook VBA and Custom Forms 0
M White square in body of Outlook Messages (O2016 Version 2012 32bit Click To Run) Using Outlook 4
P Forwarding emails issue with special characters replacing text body Using Outlook 1
Witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
J Autoreply email recieved from specific sender after deleting some text from body. Using Outlook 0
S Body text of Email from invite date/time Outlook VBA and Custom Forms 7
A How To Get Body of All Emails to view in Blue Using Outlook 1
A How to get body of all emails in outlook 2016 to view in blue color Using Outlook 1
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
L dynamic and static dates in Outlook contact "notes" ie. body Using Outlook 2
L Wierd Office 365 Contact unable to edit body of random contacts Using Outlook 5
P Insert link in email body to attached document in Outlook 365 Outlook VBA and Custom Forms 0
W Space in an Outlook appointment body Using Outlook 0
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
J VBA Outlook : Subject line : Cut and Paste name to heading , number to very end of the body of Email Outlook VBA and Custom Forms 1
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
E Copying the whole e-mail body into excel Outlook VBA and Custom Forms 0
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
E Copy e-mail body from outlook and insert into excel Outlook VBA and Custom Forms 3
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5

Similar threads

Back
Top