Access to MIME headers in Outlook with Add-in Express

Add-in Express™ Support Service
That's what is more important than anything else

Access to MIME headers in Outlook with Add-in Express
 
Mark Bertoglio




Posts: 16
Joined: 2009-08-10
Hello,
I'd like to do some processing on incoming emails in Outlook. These emails will have custom MIME header allowing me to determine which emails to process. The Outlook.MailItem class doesn't seem to expose the MIME headers. Is what I am doing possible with Add-in Express?

Thanks,
Mark
Posted 16 Jun, 2010 20:17:09 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Mark,

UPDATE 20-Jul-2016. The code fragments are modified to release the PropertyAccessor COM object.

At http://blogs.msdn.com/b/zainnab/archive/2008/07/01/using-visual-studio-2008-vsto-outlook-to-pull-out-rfc-822-header-data.aspx, I've found the following code:

CS 

// get a reference to our mail item 
Outlook.MailItem curMail = (Outlook.MailItem)this.OutlookItem; 
// use the property accessor to get info into our textBox 
Outlook.PropertyAccessor propertyAccessor = curMail.PropertyAccessor;
textBox1.Text = (string)propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E"); 
Marshal.ReleaseComObject(propertyAccessor); propertyAccessor = null;


VB 

' get a reference to our mail item
Dim curMail As Outlook.MailItem = Me.OutlookItem 
' use the property accessor to get info into our textbox
Dim propertyAccessor as Outlook.PropertyAccessor = curMail.PropertyAccessor
TextBox1.Text = curMail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E") 
Marshal.ReleaseComObject(propertyAccessor)
propertyAccessor = Nothing


Hope this helps.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Jun, 2010 11:12:33 Top
Mark Bertoglio




Posts: 16
Joined: 2009-08-10
Thanks Andrei, I am using Addin Express 2009 .NET was not finding the PropertyAccessor field in the Outlook.MailItem object. I created my project using the version neutral assemblies. I created a temp project where I selected "Use Primary Interop Assemblies" rather than "Use version neutral assemblies" and the PropertyAccessor field of Outlook.MailItem was available. What are the ramifications of not using version neutral assemblies? Does this mean that my addin will only work with the version of Outlook that I have installed (2007) and not with other versions of Outlook?

Thanks,
Mark
Posted 18 Jun, 2010 12:36:15 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hi Mark,

Please see http://www.add-in-express.com/creating-addins-blog/2010/03/16/interop-assemblies-late-binding/.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2010 07:21:27 Top