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};
service.AutodiscoverUrl(_mailbox);
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;
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.
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");
else
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.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.