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

Free Support Forum - aspose.com

Html Body in email read by ImapClient

We are using ImapClient to read email items from a specific folder served by MS Exchange. The app uses the ImapClient.ListMessages() method to populate an ImapMessageInfoCollection from which we iterate through the ImapMessageInfo objects. For each ImapMessageInfo object, we retrieve a MailMessage object using ImapClient.FetchMessage() method, passing the UniqueId from ImapMessageInfo.

In our development environment, email messages with html bodies come through with MailMessage.HtmlBody populated and MailMessage.IsBodyHtml 'true'. The same email messages in the production environment come through with HtmlBody not populated and IsBodyHtml 'false'.

We would like to have HtmlBody populated in production. What determines whether or not HtmlBody is populated and IsBodyHtml is set to 'true' or 'false'?

Thanks!

Hi,

Thanks for considering Aspose.

When the message is loaded in MailMessage class, it automatically determines whether it contains Html text or not and sets the HtmlBody and IsBodyHtml properties accordingly.

Is there any difference in code (application) that you run on development and production machines?
Are both dev/prod machines running same version of Exchange Server?

The code is the same for both environments, except it reads from a different folder ('PARSE' in dev, 'INBOX' in production).

Both dev and prod use the same Exchange server.

What specifically does it use to automatically determine whether the email contains Html text or not? Is it an Exchange setting, or something at the user level?

I have run the process through the debugger in dev, and there is clearly content in both HtmlBody and TextBody, and the content is different.

In production, we have set log messages in the code that evalutate and report on the values of IsBodyHtml and HtmlBody when it chooses to use TextBody. In production, IsBodyHtml is false and IsStringNullOrEmpty(HtmlBody) is true.

The only difference is, we manually copy (through Outlook) the messages into the PARSE folder in dev to cause them to be processed. Does that act of copying somehow force the body to be Html?

bump

It would be very helpful to us to know:

What specifically does Aspose use to automatically determine whether the email contains Html text or not? Is it an Exchange setting, or something at the user level?

We manually copy (through Outlook) the messages into the PARSE folder in dev to cause them to be processed. Does that act of copying somehow force the body to be Html?

Thanks!

Hi,

It depends on the contents of the message. If the message itself contains Html text formatting, Aspose.Network should set HtmlBody property to the Html text.

Could you please save the messages from the “parse” folder as msg file to disk, using Microsoft Outlook. And load these msg files using MailMessage class and check if it populates the message correctly or not?

I could probably save them as .msgs and read them in dev...

But the problem never manifests itself in dev, only production.

In dev, the messages come through with HTML formatting, and there is content in the HtmlBody object (as well as text content in TextBody), and IsBodyHtml is always true.

In production, the same messages, from the same Exchange server, come through with HtmlBody empty and IsBodyHtml set to false.

So are you saying Aspose specifically looks at the contents of the message, and only the contents of the message -- and no other Exchange setting or other environment-type variable, setting, etc -- to determine whether or not to populate the HtmlBody and how to set IsBodyHtml?

Thanks!

Hi,

There are no specific Exchange settings. If you can view the messages from “parse” folder in MS Outlook and can view the Html body in the Outlook, then Aspose should also load the Html content.

When you copy the messages from one folder to another using Outlook, does the messages loose Html formatting?

I just wanted to test if there is any difference in a message that:

  1. originally exists in the Inbox folder and
  2. copied via Outlook to the “parse” folder

The ones in dev, that always work, are manually copied into the 'PARSE' folder. That where the program looks for records to process, so we can control the amount of records that get processed.

The ones in production are taken straight from INBOX, untouched.

Looking at the records in dev that got copied into the PARSE folder, they contain things like underlining formatting in the html, which doesn't seem like it would be created by Outlook as part of the act of copying.

Did you ever get a resolution on this or figure out what was going on?

We're doing the same thing you are:

We are using ImapClient to read email items from a specific folder served by MS Exchange. The app uses the ImapClient.ListMessages() method to populate an ImapMessageInfoCollection from which we iterate through the ImapMessageInfo objects. For each ImapMessageInfo object, we retrieve a MailMessage object using ImapClient.FetchMessage() method, passing the UniqueId from ImapMessageInfo.

Last night somebody changed something somewhere and I know it wasn't the code. Before today the IsBodyHtml flag was alway false and the TextBody field always contained just the plain text regardless if the actual message was Html formatted or not.

Now the IsBodyHtml flag is being set correctly and the TextBody really contains the original html formatted body.

I'm betting there was a change made to our Exchange infrastructure.

Hi,


There were some IMAP related fixes in the recent release of Aspose.Network for .NET. Could you please check if you are now using an updated version of Aspose.Network.dll?

I just ran few tests on Exchange Server using ImapClient, IsHtmlBody was returning the correct values, depending on the message.