Free Support Forum - aspose.com

How to Read MAPIMessage Property From Outlook.MailItem?

Dear Support,

I was able to find something in Aspose forum close to what I want, but the code was Load From File.

Is there a way to Pass Outlook.MailItem to MAPIMessage ?
or
Is there a way to Convert Outlook.MailItem to Aspose.Network.Mail.MailMessage?

But my input is Outlook.MailItem mi

? // Aspose.Network.Mail.MailMessage m = (Aspose.Network.Mail.MailMessage) mi;
MapiMessage msg = MapiMessage.FromMailMessage(m, OutlookMessageFormat.Unicode);

Thanks.
Regards Dat.

public string get_propertytag_from_file(string msgfilename, string tagname)
{

string tagvalue = string.Empty;

// Load MSG file
MapiMessage msg = MapiMessage.FromFile(msgfilename);

MapiPropertyCollection properties = msg.NamedProperties;

// Read all properties inforeach loop
foreach (MapiNamedProperty mapiNamedProp in properties.Values)
{
if (mapiNamedProp.NameId == tagname)
{
tagvalue = mapiNamedProp.Tag.ToString();

break;
}
}

return tagvalue;

}

Hi Dat,

Thank you for inquiry.

Do you mean Microsoft.Office.Interop.Outlook.MailItem class? I am sorry, there is no such method that could do this.

It might work if you somehow save the message using Outlook.MailItem in MSG format to stream/file and then use Aspose.Network’s MailMessage or MapiMessage class to load it from that stream/file.