Reply Email

Hello,
I use my code to return the received mails.
If I have an answer to an email in my inbox, the content of this email will display empty.

ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri);
SPList list = root.Lists[CheckList(root)];
//
foreach (ExchangeMessageInfo message in msgCollection)
{
MailMessage msgInfo = client.FetchMessage(message.UniqueUri);
if (!EmailExist(message, root, msgInfo))
InsertMail(msgInfo, message, root, list);
else
break;
}



private void InsertMail(MailMessage message, ExchangeMessageInfo exchangeMessageInfo, SPWeb web, SPList list)
{
SPSecurity.RunWithElevatedPrivileges(() =>
{
try
{
SPListItem item = list.AddItem();
item[SPBuiltInFieldId.Title] = message.Subject;
item[MATQConstants.FIELD_MATQ_From] = message.From;
if (message.To.Count > 1)
item[MATQConstants.FIELD_MATQ_TO] = message.To.Aggregate((x, next) => x + “;” + next);
else
item[MATQConstants.FIELD_MATQ_TO] = message.To;
if (message.CC.Count > 1)
item[MATQConstants.FIELD_MATQ_CC] = message.CC.Aggregate((current, next) => current + “;” + next);
else
item[MATQConstants.FIELD_MATQ_CC] = message.CC;
item[MATQConstants.FIELD_MATQ_Body] = message.HtmlBody;
item[MATQConstants.FIELD_MATQ_Date] = message.Date;
item[MATQConstants.FIELD_MATQ_Status] = “0”;
SaveImage(message, web);
if (exchangeMessageInfo.HasAttachments)
{
SPAttachmentCollection fileAttch = item.Attachments;
foreach (Attachment attachment in message.Attachments)
{
byte[] buffer = new byte[(int)attachment.ContentStream.Length];
attachment.ContentStream.Read(buffer, 0, (int)attachment.ContentStream.Length);
attachment.ContentStream.Close();
fileAttch.Add(GetValidFileName(attachment.Name), buffer);
}
}
item.Update();
}
catch (Exception ex)
{
new BizWFException(ex);
}
});

}


Best Regards,
Nacata

Hi Nacata,

Thank you for writing to Aspose support.

I have tested this issue at my end as per the scenario below and was unable to face any such problem as you have mentioned. The test was carried out using the latest version of Aspose.Email for .NET 4.4.0 with a test Exchange Server 2010 (Account-A) and Gmail account (Account-B). If your test scenario is different than this, please share with us so that we can further investigate the issue for assisting you.

Test Scenario:


  1. Email was sent from Account-A to Account-B
  2. The email was replied from Account-B
  3. Replied email was retrieved from Account-A Inbox using Aspose.Email and the contents were available as shown here
As you can see from the screenshot, the contents were available as replied from Account-B. The following sample code was used for testing this issue.

Sample Code:

IEWSClient client = GetAsposeEWSClient1();

ExchangeMessageInfoCollection coll = client.ListMessages("Inbox");

foreach (ExchangeMessageInfo msgInfo in coll)

{

MailMessage msg = client.FetchMessage(msgInfo.UniqueUri);

Console.WriteLine(msg.Subject);

Console.WriteLine(msg.Body);

}