Read custom property from Aspose.MailMessage loaded from EWS

Hi Guys,

I have the followed code that uses Microsoft’s Exchange Web Services api. It connects to exchange, pulls a mail message given a specific ID and reads two custom properties.

I need to be able to accomplish the same thing with Aspose.

I CAN get it to load the mail message from Exchange using your API but I cannot work out how to pull the properties.

Can you please advise me how to convert the code below to read the properties?

public class MailPropertyNames
    public const string TagsPropertyName = "ResearchEmailTags";
    public const string EffectiveDatePropertyName = "ResearchEmailEffectiveDateyyyyMMdd"; 


var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2) {UseDefaultCredentials = true};

var mail = EmailMessage.Bind(service, new ItemId(id));

var msg = new Emails.Domain.Model.EmailMessage();
msg.Id = id;

var tags = string.Empty;
var propDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, MailPropertyNames.TagsPropertyName, MapiPropertyType.String);
mail.Load(new PropertySet(BasePropertySet.FirstClassProperties, propDefinition));
mail.TryGetProperty(propDefinition, out tags);
msg.MacroTags = tags;

var effectiveDateStr = string.Empty;
DateTime effectiveDate;
propDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, MailPropertyNames.EffectiveDatePropertyName, MapiPropertyType.String);
mail.Load(new PropertySet(BasePropertySet.FirstClassProperties, propDefinition));
mail.TryGetProperty(propDefinition, out effectiveDateStr);
if (!string.IsNullOrEmpty(effectiveDateStr))
    if (DateTime.TryParseExact(effectiveDateStr, "yyyyMMdd", new CultureInfo("en-GB"), DateTimeStyles.AssumeLocal, out effectiveDate))
        msg.EffectiveDate = effectiveDate;

Many thanks,


Hi James,

Thank you for writing to Aspose support team.

We are analyzing your requirement here and need the sample message which is downloaded from the exchange server and contains these properties. It will help us to observe the properties and provide appropriate code to read them.

Hi Muhammad,

Please find a sample message attached. I have checked with Outlook Spy and both properties are available in the email.

Many thanks,


Hi James,

Thank you for providing the sample message.

I have tried to retrieve the required custom properties from the MailMessage but could not retrieve it. However if we load this message directly to MapiMessage, we can retrieve them as shown in the following sample code.

string path = url + "Email_640933\\641501\\";

MapiMessage mapi = MapiMessage.FromFile(path + "FW Testing 6th july2.msg");

bool bIsFound = false;

foreach (MapiNamedProperty property in mapi.NamedProperties.Values)
    if (property.NameId == "ResearchEmailEffectiveDateyyyyMMdd" || property.NameId == "ResearchEmailTags")
        Console.WriteLine(property.NameId + "," + property.ToString());
        bIsFound = true;

if (bIsFound)
    Console.WriteLine("Properties found in MapiMessage.FromFile");
    Console.WriteLine("Properties not found in MapiMessage.FromFile");

However, as these properties are not available, through MailMessage directly or MapiMessage.FromMailMessage, therefore a ticket is logged under id: EMAILNET-34871 for further investigation by the product team. I shall write here as soon as some feedback is received in this regard.