Hi There,
I am trying to load (.msg) file and its properties by using following code snippet.
MapiMessage pMail = null;
MailMessage Obj_MailMessage = null;
MailMessageLoadOptions loadOptions = null;
Aspose.Email.Mail.Attachment attach = null;
try
{
loadOptions = new MailMessageLoadOptions();
loadOptions.MessageFormat = MessageFormat.Msg;
Obj_MailMessage = MailMessage.Load(pMsgPath, loadOptions);
pMail = MapiMessage.FromMailMessage(Obj_MailMessage, OutlookMessageFormat.Unicode);
}
catch(Exception ex)
{
}
But I see pMail(which is MapiMessage) properties I am getting SenderEmailAddress and SenderName Null. But in original Msg file SenderName is present.
I have attached msg File.I am using Aspose version 4.2.Please help.
Thanks,
Pooja
Hi Pooja,
Thank you for your inquiry.
You are using almost an year older version of Aspose.Email for .NET. The latest version of the API is Aspose.Email for .NET 5.2.0 and we recommend you to please use this latest version at your end.
Your sample message properties store is Unicode and you need to retrieve the message properties using the following code sample which checks for message properties store. Please let us know if we can be of any additional help to about this.
Code:
string dir = "624247\\";
MapiMessage mapiMsg = MapiMessage.FromFile(dir + "test.msg");
if (mapiMsg.IsStoreUnicodeOk())
{
if (mapiMsg.Properties[MapiPropertyTag.PR_SENDER_EMAIL_ADDRESS_W] != null)
Console.WriteLine(mapiMsg.Properties[MapiPropertyTag.PR_SENDER_EMAIL_ADDRESS_W].ToString());
if (mapiMsg.Properties[MapiPropertyTag.PR_SENDER_NAME_W] != null)
Console.WriteLine(mapiMsg.Properties[MapiPropertyTag.PR_SENDER_NAME_W].ToString());
}