# Getting headers from Outlook via OLE

**URL:** <https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459>\
**Category:** Windows\
**Created:** [November 20, 2013, 4:12pm UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459 "2013-11-20T16:12:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamish\_Symington](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@Hamish\_Symington](https://forum.xojo.com/u/Hamish_Symington)\
**Post date:** [November 20, 2013, 4:12pm UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/1 "2013-11-20T16:12:53Z")

</div>

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  
else  
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

next[/code]

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?

---

<div class="post-metadata">

**Author:** ![John\_Hansen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@John\_Hansen](https://forum.xojo.com/u/John_Hansen)\
**Post date:** [November 20, 2013, 6:56pm UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/2 "2013-11-20T18:56:04Z")

</div>

I don’t know if this can be useful. Have a look at this link: [http://www.dimastr.com/redemption/home.htm](http://www.dimastr.com/redemption/home.htm)

---

<div class="post-metadata">

**Author:** ![Hamish\_Symington](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@Hamish\_Symington](https://forum.xojo.com/u/Hamish_Symington)\
**Post date:** [November 21, 2013, 9:06am UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/3 "2013-11-21T09:06:51Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![Hamish\_Symington](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@Hamish\_Symington](https://forum.xojo.com/u/Hamish_Symington)\
**Post date:** [November 21, 2013, 9:56am UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/4 "2013-11-21T09:56:14Z")

</div>

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  
session.Logon

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  
next

session.LogOff[/quote]

---

<div class="post-metadata">

**Author:** ![Horacio\_Vilches](https://forum.xojo.com/letter_avatar_proxy/v4/letter/h/ad7895/32.png) [@Horacio\_Vilches](https://forum.xojo.com/u/Horacio_Vilches)\
**Post date:** [October 29, 2019, 6:43am UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/5 "2019-10-29T06:43:02Z")

</div>

Hello  
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

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [October 29, 2019, 7:09am UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/6 "2019-10-29T07:09:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:56pm UTC](https://forum.xojo.com/t/getting-headers-from-outlook-via-ole/12459/7 "2020-10-29T16:56:55Z")

</div>


