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

Free Support Forum - aspose.com

MapiMessage.MessageClass property always returns IPM.Note regardless of what it actually is

Hello,

I'm trying to retrieve the MessageClass for retrieved messages, but it does not seem possible. Either the property is missing altogether from the Aspose Objects, or it is not correct. I am using Aspose.Network.dll version 4.9.0.0

PROBLEM: the MapiMessage MessageClass property ALWAYS returns IPM.Note, even though my query may only be setup to return REPORT.IPM.Note.NDR messages.

The only way I've found to get it at all is by creating a MapiMessage from a MailMessage, but when you do this, the PR_MESSAGE_CLASS property seems to always get set to IPM.Note, which results in the MessageClass property returning IPM.Note.

Also, the documentation for the property in Aspose is not correct, it is a copy of the description for SubjectPrefix.

There does not seem to be anyway, anywhere within Aspose.Network to actually retrieve the correct MessageClass for a message. If there is, please tell me how.

It seems like it should be on the MessageInfo object, as well as the MailMessage object and the MapiMessage.MessageClass property needs to be set correctly.

If I display the messages in Outlook, and display the MessageClass field, it shows the expected values, but they do not appear to be available anywhere in the Aspose.Network objects.

Here is an example that reproduces the problem, assuming you have some NDRs in the target mailbox.

public void AsposeExampleWrongMessageClassForNDRs(string exchangeServerName,string mailboxName)
{
//
// Default to the current users network credentials
//
NetworkCredential mailboxCredentials = System.Net.CredentialCache.DefaultNetworkCredentials;
string mailboxUri = string.Format("http://{0}/Exchange/{1}/",exchangeServerName,mailboxName);

Console.WriteLine("MailboxUri=[{0}]",mailboxUri);

ExchangeClient client = new ExchangeClient(mailboxUri,mailboxCredentials);

Console.WriteLine("MailboxSize={0}",client.GetMailboxSize());

Console.WriteLine("Retrieving MailboxInfo...");

ExchangeMailboxInfo mailbox = client.GetMailboxInfo();

string folderenc = HttpUtility.HtmlEncode(mailbox.InboxUri);

const string shallowFormatString = "SELECT \"DAV:contentclass\""
+ ",\"urn:schemas:mailheader:subject\""
+ ",\"urn:schemas:mailheader:from\""
+ ",\"urn:schemas:mailheader:to\""
+ ",\"urn:schemas:mailheader:cc\""
+ ",\"urn:schemas:mailheader:message-id\""
+ " FROM SCOPE"
+ "('shallow traversal of \"{0}\"')"
+ " WHERE "
+ "\"http://schemas.microsoft.com/exchange/outlookmessageclass\" = 'REPORT.IPM.Note.NDR' "; // Only returns NDR

string query = string.Format(shallowFormatString, folderenc);

try
{
Console.WriteLine("Retrieving Inbox Messages for InboxUri=[{0}]",mailbox.InboxUri);
Console.WriteLine("query: {0}",query);
ExchangeMessageInfoCollection msgInfos = client.ListMessages(mailbox.InboxUri, query);
Console.WriteLine("Count is " + msgInfos.Count);
int i = 0;
int iMax = 5;
foreach (ExchangeMessageInfo msgInfo in msgInfos)
{
i++;
Aspose.Network.Mail.MailMessage msg = client.FetchMessage(msgInfo.UniqueUri);
MapiMessage mapiMsg = MapiMessage.FromMailMessage(msg);
//NOTE: mapiMsg.MessageClass is ALWAYS IPM.Note regardless of what it should be
Console.WriteLine("MessageClass={0}; Subject={1}",mapiMsg.MessageClass,mapiMsg.Subject);
if (i >= iMax) break;
}
}
catch (ExchangeException ex)
{
Console.WriteLine("Exception: {0}",ex.ToString());
}
}

Hi,

We will look into it and will get back to you soon.