Solved

Stringbuilder

Posted on 2012-03-15
4
233 Views
Last Modified: 2012-03-16
Hello,

I am using string builder to create a table that will go into an email.

Basically this works fine but what I want to do is have a table, the the first row spans across several columns.
then the second row would have several columns.

Is there anyway to have a table row span multiple columns using SB?

Thank You.
0
Comment
Question by:Wildone63
4 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 37725926
Not sure how you are doing this, but if you want a table row to span several column then all you do is add the colspan attribute to the td, i.e

<table>
<tr>
<td colspan="2">Spans two columns</td>
</tr>
<tr>
<td>First Column</td>
<td>Second Column</td>
</tr>
</table>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37726111
Another approach is to generate an HtmlTable structure, and then render the control to a StringWriter and an HtmlTextWriter.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37726570
private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("your_email_address@gmail.com");
                mail.To.Add("to_address");
                mail.Subject = "Test Mail - 1";

                mail.IsBodyHtml = true;
                string htmlBody;

                htmlBody = "<table><tr><td colspan="2">2 col</td></tr><tr><td>First Column</td><td>Second Column</td></tr></table>";

                mail.Body = htmlBody;

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                MessageBox.Show("mail Send");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

Open in new window


Ref:http://csharp.net-informations.com/communications/csharp-html-email.htm
Have a look at this one as well:-
http://www.emailarchitect.net/easendmail/kb/csharp.aspx?cat=6;

you can always replace the htmlbody string with stringbuilder.
0
 
LVL 1

Author Closing Comment

by:Wildone63
ID: 37729257
Exactly what I was looking for.

Thank You!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question