Solved

Stringbuilder

Posted on 2012-03-15
4
229 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now