We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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\”;<o:p></o:p>

MapiMessage mapi = MapiMessage.FromFile(path + “FW Testing 6th july2.msg”);<o:p></o:p>

bool bIsFound = false;<o:p></o:p>

foreach (MapiNamedProperty property in mapi.NamedProperties.Values)<o:p></o:p>


if (property.NameId == “ResearchEmailEffectiveDateyyyyMMdd” || property.NameId ==“ResearchEmailTags”)<o:p></o:p>


Console.WriteLine(property.NameId + “,” + property.ToString());<o:p></o:p>

bIsFound = true;<o:p></o:p>



if (bIsFound)<o:p></o:p>

Console.WriteLine(“Properties found in MapiMessage.FromFile”);<o:p></o:p>


Console.WriteLine(“Properties not found in MapiMessage.FromFile”);<o:p></o:p>

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.