From whose mailbox did a .MSG file originate?

The MailMessage and MapiMessage classes both provide a list of recipients. We are reading .msg files received on CD. Is there a reliable, consistent way of determining which recipient is the one from whose mailbox the .msg originated?

For example, Jack sends Bob, Tara, and Mo an email, and Mo saves it to a .MSG file. Our application (using Aspose.EMail for .NET) reads the .MSG file - how can we tell the .MSG file is Mo’s copy?

Or, if Jack (the sender) saves the sent message to a .MSG file, is there a way to tell it is Jack’s copy?

Hi Nick,


Thanks for writing to Aspose.Email support team.

I have analyzed the requirement and found that if a MSG is saved by a recipient, it always contains a property named PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W.

This above mentioned property is not present there if the MSG is saved by the sender. Please give a try to the following code and let us know your feedback. Its assumed that different copies of Jack, Bob, Tara and Mo are there in the same folder say “EMAIL_435071” with extension “.msg”.

static void EMAIL_435071()
{
foreach (string file in Directory.GetFiles(“EMAIL_435071\”, “*.msg”))
{
EMAIL_435071_SUB(file);
}
}
static void EMAIL_435071_SUB(String szMsgName)
{
MapiMessage mapiMessage = Aspose.Email.Outlook.MapiMessage.FromFile(szMsgName);
MapiPropertyCollection properties = mapiMessage.Properties;
//if (properties.Contains(MapiPropertyTag.PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W) || properties.Contains(MapiPropertyTag.PR_RECEIVED_BY_EMAIL_ADDRESS_W))
if (properties.Contains(MapiPropertyTag.PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W))
{
Console.WriteLine(“RECEIVER:”+szMsgName + properties[MapiPropertyTag.PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W].ToString());
}
else
{
Console.WriteLine(“SENDER:” + szMsgName + properties[MapiPropertyTag.PR_SENDER_NAME_W].ToString());
}
}

Thanks so much Kashif.

If I save a message from an Outlook PST file:

  • The PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W property is not present.
  • The PR_RECEIVED_BY_EMAIL_ADDRESS_W property is present, and works, returning an SMTP address.

If I save a message from Exchange:

  • The PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W property is present and returns an LDAP address.
  • The PR_RECEIVED_BY_EMAIL_ADDRESS_W property is present and returns an LDAP address.

My next task will be resolving the LDAP address to SMTP, which will have to wait until another day.

In any event, thanks, you’ve answered my question.

Hi Nick,


Thank you for the feedback.

It’s good to know that the provided information worked for you. Please feel free to contact us if you have any additional query/inquiry related to Aspose.Email. We will be glad to assist you further.