Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access all headers programmatically?

Posted on 2002-07-11
5
Medium Priority
?
342 Views
Last Modified: 2008-02-26
Can anyone tell me if there is a way to get all the headers of an outlook message from a COM plugin? I have gotten access to the _MailItem, and can get headers like To:, Subject:, etc. using get_To, get_Subject, etc. But the _MailItem interface doesn't seem to allow me to get, for example, Return-Path. Is there a way I can get access to the "raw" headers, or to any headers that Outlook didn't know what to do with?

Jon Webb
0
Comment
Question by:jonawebb
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Neo_mvps earned 600 total points
ID: 7147922
Hi Jon,

The header information is not (directly) exposed in the Outlook Object Model.  Since it looks like you are developing in C/C+ and my experience is in VB, forgive me for the tip I'm going to give if the terminology isn't right.

The MailItem exposes a hidden property named MAPIOBJECT.  This property returns an IUnknown interface.  You would have to query this interface to get the Extended MAPI interface (IMessage?) to the object and then read transport header property.

Cheers,
/Neo

PS - And for those using VB.  I would get the Entry ID/Stored ID and acquire the message via Collaboration Data Objects 1.21 and then read the field PR_TRANSPORT_MESSAGE_HEADERS.

PS - Jon, there is a really good MAPI forum list at peach ease lsoft where this quesiton could be answered from the C/C++ perspective.


0
 

Author Comment

by:jonawebb
ID: 7150108
Your answer, while not quite right, was invaluable in pointing me in the right direction. I'd be happy to give you full credit for the answer if you'll post it as such.

The solution I came up with was this:

#include <mapix.h>
#include <initguid.h>
#include <mapiguid.h>

     IDispatch *pItem;
        // ... initialize pItem by lookup in an Outlook folder

     CComQIPtr<Outlook::_MailItem> pMail(pItem);
     ATLASSERT(pMail);
     IUnknown* pUnk = NULL;
     pMail->get_MAPIOBJECT(&pUnk);
     ATLASSERT(pUnk);
     CComQIPtr<IMAPIProp, &IID_IMAPIProp> pMAPIProp(pUnk);
     ATLASSERT(pMAPIProp);
     SPropTagArray ar = {0};
     ULONG nProps = 0;
     SPropValue *arProps = NULL;
     char *szResult = NULL;

     ar.cValues = 1;
     ar.aulPropTag[0] = PR_TRANSPORT_MESSAGE_HEADERS;
     pMAPIProp->GetProps(&ar, PT_UNSPECIFIED, &nProps, &arProps);
0
 

Author Comment

by:jonawebb
ID: 7150125
I forgot to add:
1) The IDispatch returned by get_MAPIOBJECT supports two interfaces that I could find documentation on: IMAPIProp and IMAPISession. The fact that these interfaces are supported is undocumented anywhere; I found them by stepping through the assembly.
2) IMAPIProp is what you use to get the headers. In my code, GetProps returns the header as a string in the arProps parameter.
3) There are two different kinds of IMessage interfaces. The Microsoft documentation is even more elliptical and unorganized than usual.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7150202
Very cool and thanks for the grade of A.
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7150206
oops... should have said B.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 trialware OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their Exchange server is no longer available or other critical issues with Exchange server or impo…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question