C# ASP.NET Interact with MS Outlook

I am sending email utilizing SMTP on a server via my Web Application in C#.  I am noticing that different MS outlook clients interpret the messages in different ways, I.e. some fit on one page, and others extend to multiple pages - depending upon which users machine I look at.

Is there a way to programmatically control how different user's client MS Outlook's interpret the email.

I would like to format all emails so they fit within a certain border/margin for example.

Thanks.
jamesdean666Asked:
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.

rajapandian_81Commented:
jamesdean666,

You can send the mail in HTML format.

Set the HTML as body for mail object and set the IsBodyHTML property of mail object as true.
0
jamesdean666Author Commented:
Hmm...  I am not sure what you mean by 'Set the HTML as body for mail object'.  I have the IsBodyHTML property set on my mail object.. here's my code.. can you please provide some sample code or corrections?

        public static void SendEmail(MailMessage message)
        {
            SmtpClient smtp = new SmtpClient("PILCHARD");            
            message.IsBodyHtml = true;            
            smtp.Send(message);            
            return;
        }

Thanks.
0
rajapandian_81Commented:
Instead of setting simple text as body for mail, set HTML as body like below:

public static void SendEmail(MailMessage message)
{
     SmtpClient smtp = new SmtpClient("PILCHARD");
     string strBody = "<html><head><title>Test</title></head><body><table width="500px"><tr><td align="center">Hai</td></tr></table></body></html>";
     message.Body = strBody;
     message.BodyFormat = MailFormat.Html;
     smtp.Send(message);            
     return;
}

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

jamesdean666Author Commented:
Thanks for the response...

I am using C# VS Studio 2008.. I don't see the following line as valid in this environment:

message.BodyFormat = MailFormat.Html;

There is no BodyFormat, or MailFormat available.

Thanks
0
rajapandian_81Commented:
jamesdean666:

I am using VS 2005.
If you have IsBodyHtml property, you can use that.

Change the line
message.BodyFormat = MailFormat.Html;

to
message.IsBodyHtml = true;  
0
jamesdean666Author Commented:
Thanks.. I am successfully converting the output to HTML now..

i just printed the output on a Microsoft Exchange server account and it all fits on one page.

My colleague printed it on her local PC's MS Outlook client, and it doesn't fit on one page..

Any ideas?
0
rajapandian_81Commented:
Have you set width and height for table which is inside HTML?
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
jamesdean666Author Commented:
Bingo... it was the width formatting..  Thanks.
0
jamesdean666Author Commented:
Thanks.
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
ASP.NET

From novice to tech pro — start learning today.