A
Andy Baldwin
So, I have the following function defined in C#
public string InternetHeaders(Outlook.MailItem mi) {
object missingVal = System.Reflection.Missing.Value;
MAPI.Session session = new MAPI.SessionClass();
session.Logon("", missingVal, missingVal,
missingVal, missingVal,
missingVal, missingVal);
MAPI.Message m = (MAPI.Message)session.GetMessage(mi.EntryID,"");
System.Console.WriteLine(m.Fields);
MAPI.Fields fields = (MAPI.Fields)m.Fields;
string headers = fields["&H7D001E"];
return null;
}
MAPI is my CDO.dll reference, and Outlook is the Outlook API
reference. The problem lies in the second to last line where I am
attempting to get the message headers. Slipstick refers me to
http://support.microsoft.com/?kbid=194870
which gives a VB example in which it shows using the fields collection
like a c# indexer (which is what this code is based on). Problem is
that using either square brackets or parenthesis both give me build
errors ("Cannot apply indexing with [] to an expression of type
'MAPI.Fields'" or "'fields' denotes a 'variable' where a 'method' was
expected"). My autocomplete/tooltip is inactive when I attempt to use
the [] or () as well. I then additionally tried the get_item method
like so:
string headers = (string)fields.get_Item((object)0,(object)"&H7D001E");
assuming that the second argument called propID is the same everywhere
and got
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: [Collaboration Data Objects -
[MAPI_E_NOT_FOUND(8004010F)]]
I looked up that MAPI_E_NOT_FOUND error with no real luck. I have read
somwhere (although I can't find it again) that there were problems
using CDO under .Net. Is this true? Can anyone else suggest a quick
way to get the full message headers in .Net from an Outlook.MailItem?
I wanna parse this info and keep it to analyze for spammer trends.
Thanks in advance!!
Andy Baldwin
public string InternetHeaders(Outlook.MailItem mi) {
object missingVal = System.Reflection.Missing.Value;
MAPI.Session session = new MAPI.SessionClass();
session.Logon("", missingVal, missingVal,
missingVal, missingVal,
missingVal, missingVal);
MAPI.Message m = (MAPI.Message)session.GetMessage(mi.EntryID,"");
System.Console.WriteLine(m.Fields);
MAPI.Fields fields = (MAPI.Fields)m.Fields;
string headers = fields["&H7D001E"];
return null;
}
MAPI is my CDO.dll reference, and Outlook is the Outlook API
reference. The problem lies in the second to last line where I am
attempting to get the message headers. Slipstick refers me to
http://support.microsoft.com/?kbid=194870
which gives a VB example in which it shows using the fields collection
like a c# indexer (which is what this code is based on). Problem is
that using either square brackets or parenthesis both give me build
errors ("Cannot apply indexing with [] to an expression of type
'MAPI.Fields'" or "'fields' denotes a 'variable' where a 'method' was
expected"). My autocomplete/tooltip is inactive when I attempt to use
the [] or () as well. I then additionally tried the get_item method
like so:
string headers = (string)fields.get_Item((object)0,(object)"&H7D001E");
assuming that the second argument called propID is the same everywhere
and got
An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: [Collaboration Data Objects -
[MAPI_E_NOT_FOUND(8004010F)]]
I looked up that MAPI_E_NOT_FOUND error with no real luck. I have read
somwhere (although I can't find it again) that there were problems
using CDO under .Net. Is this true? Can anyone else suggest a quick
way to get the full message headers in .Net from an Outlook.MailItem?
I wanna parse this info and keep it to analyze for spammer trends.
Thanks in advance!!
Andy Baldwin