Reference to the mailitem the user has chosen



Hi there :)

I have a button in Outlook which allows the user to save a mail item to
an external archiving system.

If the user presses this button I need to check wether or not he has a
mail-item "active". By this I mean that the user has selected a mail in
a spesific folder that he wants to archive.

Furthermore I need to get hold of that spesific mail item with
belonging attachements.

When reading in documentations, articles and examples I can only see
how you create folders and items - not how to get a reference to an
existing one.

I write my code in C#, and has a shared add-in. This button is
displayed in every office-application.

Thank's a lot for any contribution :)



Ken Slovak - [MVP - Outlook]

ActiveExplorer is the active object in a folder view. Selected items in
ActiveExplorer are in the Selection collection. Once you have the item you
can access all its properties and its attachments.

Something like this:

private Outlook.Selection colSelect;
private Outlook.MailItem m_mail;

if (this.Application.ActiveExplorer() != Null)
colSelect = this.Application.ActiveExplorer().Selection;

m_mail = (Outlook.MailItem) colSelect[1];
// whatever

// whatever

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