After upgrading to current version (17.6), for office 365 accounts, the LisMessages method of the IEWSClient returns all messages with null in the From property for the Inbox folder of the account; messages returned with the same method for any other folders have the property correctly populated.
This is he code used (please note the “is null for inbox” comment):
public override int ListMessagesInFolder(ref GridView gridView, string folderUri, string searchText)
{
try
{
Aspose.Email.Tools.Search.MailQuery mQuery = Common.GetMailQuery(searchText);
ExchangeMessageInfoCollection msgCollection = null;
msgCollection = client.ListMessages(folderUri, Common.MaxNumberOfMessages,
ExchangeListMessagesOptions.FetchAttachmentInformation);
List messagesList = new List();
foreach (ExchangeMessageInfo msg in msgCollection)
{
if (msg.HasAttachments)
{
messagesList.Add(new Message()
{
UniqueUri = msg.UniqueUri,
Date = Common.FormatDate(msg.Date),
Subject = Common.FormatSubject(msg.Subject),
From = Common.FormatSender(msg.From),//is null for inbox
Attachment = "Several"
});
foreach (ExchangeAttachmentInfo att in msg.Attachments)
{
messagesList.Add(new Message()
{
UniqueUri = msg.UniqueUri,
Date = string.Empty,
Subject = string.Empty,
From = string.Empty,
Attachment = att.Name
});
}
}
else
{
try
{
messagesList.Add(new Message()
{
UniqueUri = msg.UniqueUri,
Date = Common.FormatDate(msg.Date),
Subject = Common.FormatSubject(msg.Subject),
From = Common.FormatSender(msg.From),//is null for inbox
Attachment = "None"
});
}
catch (Exception ex)
{
string iscript = "$.iDatixNotification({ text:'Could not load message: '" + ex.Message + ",level: 'error'});";
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "poploadm" + Guid.NewGuid().ToString(), iscript, true);
}
}
}
gridView.DataSource = messagesList;
gridView.DataBind();
gridView.Visible = true;
return msgCollection.Count;
}
catch (Exception ex)
{
var x = ex.Message;
string iscript = "$.iDatixNotification({ text:'Could not load messages: '" + ex.Message + ",level: 'error'});";
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "poploadm" + Guid.NewGuid().ToString(), iscript, true);
}
return 0;
}
Thx