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

Free Support Forum - aspose.com

Message is garbled after reading but looks fine in Outlook/OWA

Hello, we have the following situation. We have an application that reads an email from an inbox and searches it for particular string. We are able to get the email and read it but the contents are garbled once it is read out the mailbox. We have confirmed that the email is completely fine when viewed in Outlook/OWA. We recently moved this email box from exchange 2007 to 2010 and that is when the issue started occuring. The following is the code we use to get the message:


Due to company policy I cannot add a sample for review :frowning:

Please advise. Thanks! -Brent

public IIncomingMessage GetMessage(IPendingMessage pendingMessage) {
MailMessage mailMessage;
EMailBodyFormat bodyFormat=EMailBodyFormat.PlainText;
IList lstAttachments=new List();

using(ImapClient imapClient=GetClient()) {
imapClient.SelectFolder(config.SourceFolder);
mailMessage=imapClient.FetchMessage(pendingMessage.MessageId);
imapClient.Disconnect();
}
if(null==mailMessage) {
return null;
}
if(mailMessage.IsBodyHtml) {
using(MemoryStream stream=new MemoryStream()) {
mailMessage.Save(stream, MessageFormat.Msg);
stream.Position=0;
mailMessage=MailMessage.Load(stream, MessageFormat.Msg);
}
bodyFormat=EMailBodyFormat.Html;
}

int attachmentNumber=0;
foreach(Attachment attachment in mailMessage.Attachments) {
attachmentNumber++;
string attachmentName=ScrubFileName(attachment.Name, attachmentNumber);
lstAttachments.Add(attachmentName);
}
IncomingMessage incomingMsg=new IncomingMessage(mailMessage, pendingMessage, bodyFormat, lstAttachments);
return incomingMsg;
}

Hi Brent,


We are afraid for the inconvenience you are facing.

I am not sure if this might be the issue of shifting to Exchange Server 2010 as this may also depend upon the encoding of the message body. We might have a bug at Aspose.Email end as well but its not possible to test this issue without having a sample file. You can save the fetched message to the disc and then open it for examining if its contents are fine or not?

If the issue still persists, I am afraid we won’t be able to investigate the issue further until a sample message file is provided or a test account is created for us on your server with the problematic message made available on it for our investigation. You can make this thread private in case you want to share some information (sample email, test account credentials) with us and it will be only accessible to you and Aspose staff, thus preserving your privacy.

We appreciate your understanding in this regard and look forward to assist you further.

I am attaching a screen shot that shows the properties of the mailMessage object after we retrieve the message. We also saved it to a text file (using mailMessage.Save(fileStream, MessageFormat.Msg):wink:, also attached. I’m hoping you may see something here that would indicate why the message becomes so garbled once read from the mailbox.

Hi Brent,


I can see the problem with the MSG file you have provided. Could you please tell if:

  1. All the files read from the exchange server exhibit this problem?
  2. Could you please try our EWS component and confirm if the same problem occurs there too?
  3. Can you please create a test account on your server and provide us the login credentials so that we can reproduce the issue at our end and report it to our development team for further investigation?
We can also investigate this issue further if you could provide us some sample file that we can place in our Exchange server, access it via ImapClient and report it to our development team if the issue is reproducible. Your cooperation in this regard is highly appreciated.