473,409 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

How to create a table in outlook mail body programmatically

32
I'm trying to create an email message which contains a table.
in the table I have one column that contains a URLs.

because I don't want the table to be too wide I want to limit the URL column,

I tried using nowarp tags in the table but with no luck.
I tried using CSS but it seems like the outlook is removing them.

my code is:

have two function that create the HTML code:

the first which creates the table headers:
Expand|Select|Wrap|Line Numbers
  1.  
  2. private string SetEmailBody(bool _withTime)
  3. {
  4.  
  5.          string tmp;
  6.  
  7.  
  8.             tmp = "<HTML>\n <Body> \n<br> \n <table border=\"1\" cellspacing=\"0\" cellpadding=\"1\" style=\"width:1200; border:0.5px solid black;\">";
  9.  
  10.  
  11.             tmp = tmp + "<tr bgcolor=\"#999999\">\n";
  12.  
  13.  
  14.             tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div><Font Face='Arial' Size=2>ID</Font></div></td>\n";
  15.  
  16.  
  17.             if (_withTime)
  18.             {
  19.  
  20.                 tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div><Font Face='Arial' Size=2>Date</Font></div></td>\n";
  21.  
  22.  
  23.                 tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div><Font Face='Arial' Size=2>Time</Font></div></td>\n";
  24.  
  25.  
  26.             }
  27.  
  28.  
  29.             tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div style=\"width : 40px; word-break : break-all; overflow : hidden; text-overflow: hidden;\"><Font Face='Arial' Size=2>Link</Font></div></td>\n";
  30.  
  31.  
  32.  
  33.             tmp = tmp + "</tr>\n";
  34.  
  35.  
  36.  
  37.             return tmp;
  38. }
  39.  

the second which add to the table new row:
Expand|Select|Wrap|Line Numbers
  1. private string EmailBodyAddLine(string ID, string time, string date, string URL, bool _withTime)
  2. {
  3.  
  4.             string tmp = "<tr>\n";
  5.  
  6.             //ID
  7.             tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div id=\"idcol\"><Font Face='Arial' Size=2>%id%</Font></div></td>\n".Replace("%id%", ID);
  8.  
  9.  
  10.             //Include time stemp
  11.         if (_withTime)
  12.         {
  13.         tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div id=\"timecol\"><Font Face='Arial' Size=2>%date%</Font></div></td>\n".Replace("%date%", date);
  14.  
  15.         tmp = tmp + "<td align=center style=\"border:0.5px solid black;\"><div id=\"timecol\"><Font Face='Arial' Size=2>%time%</Font></div></td>\n".Replace("%time%", time);
  16.         }
  17.  
  18.  
  19.  
  20.             tmp = tmp + "<td align=left style=\"border:0.5px solid black;\"><div style=\"height : 19px; width : 40px; word-break : break-all; overflow : hidden; text-overflow: hidden;\"><Font Face='Arial' Size=2>%URL%</Font></div></td>\n".Replace("%URL%", URL);
  21.  
  22.  
  23.  
  24.             tmp = tmp + "</tr>\n\n";
  25.  
  26.  
  27.             return tmp;
  28. }
  29.  

then I close the final string with
"</table>\n </html> "

and save it to the outlook draft

But when open in the outlook draft, seems like the CSS is partial working
for ex' the <div> size limit and the text over-flow are not implemented.

Thanks
May 30 '10 #1
1 20349
PRR
750 Expert 512MB
You can insert html in to email body( stringbuilder). I don't think it should be a problem.
HTML email using Outlook
May 31 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Henri | last post by:
Hi I would like to use a User Control to render the body of the mail I send. The problem is that my application is not an ASP.NET page so I can't use any Page reference to call LoadControl What...
0
by: Mads Westen | last post by:
Hi, I got some code working to create a new mail in Outlook and displaying it. I'm currently using the "Outlook._MailItem". I want to be able to use the standard stationary, which is set up in...
3
by: daveward10 | last post by:
I want to be able to drag and drop an Outlook mail message (Outlook 2003) onto a windows form (C# 2003) so that my application can then save the file (in the same was as if I were to drag and drop...
2
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
To all, I was wondering if someone has sample VB.NET code that will help me send rows of a gridview into a body section of an e-mail. My goal is to present multiple rows within a gridview to a...
1
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
0
by: BlackMustard | last post by:
hi i want to modify font, size and color of selected text in an outlook mail body programatically (that is, with a macro in outlook vba). is there a simple way to use some object property like...
2
by: =?Utf-8?B?U2hydXRpIERlc2hwYW5kZQ==?= | last post by:
I am developing an application in vb.net 2005 to send email via outlook. The mail body contains key - value pairs like Account Number : 232323 CRS Number : 872732 Name :...
1
by: Mahesh J K | last post by:
Hi, Pls help me in solving this problem. How to trigger radio button element's eventhandler from the mail body of the mail I am trying like this... strHTMLBody = "<html><head><script...
2
by: venutaurus539 | last post by:
Hi,, How can we access the time of message received ( UTC time) of an outlook mail in python? As far as I know the time which it displays in the mail is not the exact time... this UTC time will be...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.