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?
 
rajapandian_81Connect With a Mentor Commented:
Have you set width and height for table which is inside HTML?
0
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
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
 
jamesdean666Author Commented:
Bingo... it was the width formatting..  Thanks.
0
 
jamesdean666Author Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.