Export or copy the header and body of mail message

G

gary

There is no command which allows a copy of the header and body of an e-mail
message. At the moment the only workaround I know is to "forward" the message
which then gives me both the header and body and then I copy and paste it as
needed e.g. into word document

Is there a VBA type command which can createa copy of a selected e-mail
message that contains both header and footer?

Sorry if my question is poorly phrased. I hope the introduction helps you
understand what I want to do.

TIA/gary
 
K

Ken Slovak - [MVP - Outlook]

What do you mean by header? Do you mean the Internet mail headers?

What version of Outlook?

You can easily get the body of the message using item.Body or item.HTMLBody,
that's no problem.

The property for the Internet headers isn't exposed to the Outlook object
model directly. In Outlook 2007 you can use the new PropertyAccessor object
to get the headers like this, assuming item is your mail item:

Dim sHeaders As String
sHeaders =
item.PropertyAccessor("http://schemas.microsoft.com/mapi/proptag/0x007D001E")
' note that this is not an URL, it's a DASL style property tag for the
headers.

In earlier versions of Outlook you can't use PropertyAccessor, so you must
use a different API to get the headers. CDO 1.21 is possible but it's an
optional installation and you will get the security prompt when you use it.
A CDO sample is at
http://www.slovaktech.com/code_samples.htm#InternetHeaders. To avoid the
security you can use the 3rd party Redemption library
(www.dimastr.com/redemption). A Redemption sample for headers is at that
site, the property tag used for the headers would be
PR_TRANSPORT_MESSAGE_HEADERS for Redemption.
 
G

gary

Hi Ken

Thanks

By header I mean the "to", "from", "cc", "bcc", and "subject". I am a novice
at VB and these protocols so I'm not sure if your suggestion applies or not.

TIA/gary
 
K

Ken Slovak - [MVP - Outlook]

No, those properties have nothing to do with Internet headers. Those
properties can be read directly using standard properties on any Outlook
MailItem object.

I'd suggest that you look at the Object Browser, which has complete lists of
all properties, methods and events for every type of Outlook object. The
Help in the Object Browser usually also contains short code snippets of
using those properties, methods and events.

Finally, you can purchase a beginner's book on Outlook programming. I'd
recommend the ones from Sue Mosher, which you can find information on at the
books pages of www.outlookcode.com, where there's also a ton of code
samples.
 

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