Getting headers from Outlook via OLE

I’m trying to read headers from a message in Outlook, via OLE, but I don’t know if it’s possible.

So far I’ve managed to read the messages in a folder (in this case the inbox):

[code] dim obj, nmspace, inbox, recipient as OLEObject
dim i, goUpTo as integer

obj = new OLEObject(“Outlook.Application”)
nmspace = obj.GetNamespace(“MAPI”)
inbox = nmspace.GetDefaultFolder(6) // inbox

if inbox.items.count > 200 then
goUpTo = 200 // Only do the first 200 messages
goUpTo = inbox.Items.Count
end if

for i = 1 to goUpTo
// do stuff with the messages in here
// eg sender email address is inbox.items(i).SenderEmailAddress


but in the final loop there’s no way as far as I can see to get the headers. In particular, I’m interested in the Message-Id header.

Is there a way to get the headers?

I don’t know if this can be useful. Have a look at this link:

Thanks, John, that does indeed look like it could be useful. Sadly, I’m not up in the slightest with how to use this in my project, so I’ll post another question for some help on that! :slight_smile:

I found some brain reserves. For anyone in future coming to look how you can use Redemption to access info from Outlook, using MAPI, here’s how.

  1. Download Redemption and register it following the instructions in the read me file.
  2. Use RB code.

[quote]dim inbox, recipient, session as OLEObject
session = New OLEObject(“Redemption.RDOSession”) // uses default MAPI session

inbox = Session.GetDefaultFolder(6)
for i = 1 to Inbox.Items.Count // nb this is 1-based, not 0-based
// e.g. Subject is inbox.Items(i).Subject
// headers are inbox.Items(i).Fields(&H7D001E)
// Message UID is inbox.Items(i).Fields(&H1035001E) - nb this has < and > around it


I’m using the above code to read emails from Outlook.
I use inbox.items(i).BODY to try to read the email message but in 99% of times it just returns chinese characters as if there was some encryption or encoding problem. What could be the solution ?
Thanks for yr help

Don’t add to old threads. If you have chinese characters then you usually have text in some simpler encoding showing up as utf16.