programmtically read internet header in c#

D

Dinesh

hello everyone,

Can anyone help with the code how to programmtically read the internet
header of the selected email using c# with the VSTO and also i have
redemption and CDO .

thank you.
 
K

Ken Slovak - [MVP - Outlook]

CDO 1.21 is not supported for managed code, use Redemption for that. Or if
you are programming against Outlook 2007 use the new PropertyAccessor object
on the MailItem.

The headers are in property PR_TRANSPORT_MESSAGE_HEADERS (0x007D001E). Get
the selected mail item from the ActiveExplorer.Selection collection. Use
Selection.Count to see how many items are selected, if it's only 1 item then
use something like this snippet:

// app == Outlook.Application object, already instantiated
Outlook.MailItem mail = (Outlook.MailItem)app.ActiveExplorer().Selection[1];
string ID = mail.EntryID;
// session is RDOSession object, already instantiated
Redemption.RDOMail rMail = session.GetMessageFromID(ID, missing, missing);
string header = rMail.Fields(0x007D001E);

Of course this snippet doesn't do any error handling or checking if the item
is a MailItem, if no items are selected or if there are any headers.
 
D

Dinesh

hi,

Actually iam using outlook 2003. Iam capturing the selection event
change in the explorer and writing a function for that like
selectionchange.In that i have to wirte a c# code to read the email header.
so when a user click the email in the inbox then the internet header of the
email should be shown in messagebox or is it possible to shown it as
seperate frame window in outlook.

Thank you.


Ken Slovak - said:
CDO 1.21 is not supported for managed code, use Redemption for that. Or if
you are programming against Outlook 2007 use the new PropertyAccessor object
on the MailItem.

The headers are in property PR_TRANSPORT_MESSAGE_HEADERS (0x007D001E). Get
the selected mail item from the ActiveExplorer.Selection collection. Use
Selection.Count to see how many items are selected, if it's only 1 item then
use something like this snippet:

// app == Outlook.Application object, already instantiated
Outlook.MailItem mail = (Outlook.MailItem)app.ActiveExplorer().Selection[1];
string ID = mail.EntryID;
// session is RDOSession object, already instantiated
Redemption.RDOMail rMail = session.GetMessageFromID(ID, missing, missing);
string header = rMail.Fields(0x007D001E);

Of course this snippet doesn't do any error handling or checking if the item
is a MailItem, if no items are selected or if there are any headers.




Dinesh said:
hello everyone,

Can anyone help with the code how to programmtically read the internet
header of the selected email using c# with the VSTO and also i have
redemption and CDO .

thank you.
 
K

Ken Slovak - [MVP - Outlook]

For Outlook 2003 there are no custom task panes, so if you want to show the
headers you would need to display a separate form in which to display them.
 
D

Dinesh

hello ken,

Thank you,

can u tell me how to display a separate form with the internet header
alone.can u also tell me how to recieve header of the selected email using
the visual c#. It would be helpful if suggest me some code or example to do
it in visual c#.

thank you once again.
 
K

Ken Slovak - [MVP - Outlook]

I already showed the code for getting the headers from Selection[1] using
C#, look at that message. For displaying a form, just create a form in VS
and add a textbox and put the headers into the textbox. That's all real
simple development that you should be familiar with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top