After moving to Exchange, Emails formated through .NET no longer formated

We moved to an Exchange 2010 server from using POP3.  Our Exchange server is not set up to use SMTP so I went and changed my code to make use of the Exchange web serveices in .net

private ExchangeService Eservice = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

private EmailMessage EMessage ;

 Eservice.AutodiscoverUrl(strEmail);
 Eservice.Credentials = new WebCredentials(strLogon, strPass);
 EMessage = new EmailMessage(Eservice);
 EMessage.ToRecipients.Add(strTo);
 EMessage.Subject = strSubject ;
 EMessage.Body = strBody;
 EMessage.Body.BodyType.Equals(BodyType.HTML);

 EMessage.SendAndSaveCopy();

Open in new window


So even with the strBody passes as "<body> Test format<br/> Test format line 2 </body>". While the email sends fine, the line break is not done and the text is lined up all together.

Passing it as text I get the same result.  using /n/r    still no line breaks.     Is there something I am missing.  Is there a setting on an exchange server?    Never had a problems with the POP3 messages going and being formated.
LWDudAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LWDudAuthor Commented:
so,  we have moved the applications back to using SMTP and opened up a specific IP range on the Exchange server.   The SMTP mail messages are working and formatting properly.  It doesn't make sense to me since the body of the messages are the same as what we were trying to send through exchangeservice and emailmessage.
0
lluddenCommented:
Here is my function I use with Exchange Web Services.  I think the only thing you are missing is setting the BodyType flag on the Body.

Public Shared Function SendMessage(ByVal ToAddress As Generic.List(Of String), ByVal Subject As String, ByVal strBody As String, ByVal CCAddresses As Generic.List(Of String), ByVal BCCAddresses As Generic.List(Of String), ByVal Attachments As Generic.List(Of String), ByVal isBodyHTML As Boolean, SendAs As String) As Integer
        Dim msg As New EmailMessage(CurrentConnection)
        If Not String.IsNullOrWhiteSpace(SendAs) Then
            msg.From = New EmailAddress(SendAs)
            msg.Sender = msg.From
        End If

        If ToAddress IsNot Nothing Then
        For Each t As String In ToAddress
            msg.ToRecipients.Add(New EmailAddress(t))
        Next
        End If
        If CCAddresses IsNot Nothing Then
            For Each t As String In CCAddresses
                msg.CcRecipients.Add(New EmailAddress(t))
            Next
        End If
        If BCCAddresses IsNot Nothing Then
            For Each t As String In BCCAddresses
                msg.BccRecipients.Add(New EmailAddress(t))
            Next
        End If
        If Attachments IsNot Nothing Then
            For Each t As String In Attachments
                msg.Attachments.AddFileAttachment(t)
            Next
        End If
        msg.Subject = Subject
        msg.Body = strBody
        If isBodyHTML Then
            msg.Body.BodyType = BodyType.HTML
        Else
            msg.Body.BodyType = BodyType.Text
        End If
        msg.SendAndSaveCopy(WellKnownFolderName.SentItems)
        Return 1
    End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LWDudAuthor Commented:
Thanks,  I've done that for HTML and it didnt seem to work, but I'll give it a try for the Text messages and see if that solves it.
0
lluddenCommented:
Here is the HTML version I used and it worked fine:
<html>
	<body>
		<p>
			Test Format</p>
		<p>
			Line 2</p></body>
</html>

Open in new window

0
LWDudAuthor Commented:
You were right Iludden, it had to do with how I was setting the body format.

if (blnIsHTML)
            {
                EMessage.Body.BodyType = BodyType.HTML;
            }
            else
            {
                EMessage.Body.BodyType = BodyType.Text;
            }

Open in new window


does work,

if (blnIsHTML)
            {
               EMessage.Body.BodyType.Equals(BodyType.HTML);
            }
            else
            {
                EMessage.Body.BodyType.Equals(BodyType.Text);
            }

Open in new window


does not do anything that we can tell.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.