1

I am sending colored text emails using smtp in c# but the content when i see in inbox it it showing as black colored text. How to send colored content using RichTextBox. RichTextBox is showing colored text when Pasted from word but the mail is showing as black content. please help me.

  1. copy the content from ms word and paste in RichTextBox(colored content)
  2. send the smtp mail with colored content as final output.

    i had already sent an email from it but it is not showing colored content in gmail.

Sai Venkat
  • 7
  • 1
  • 5
  • 3
    I think that RichTextBox makes RTF so you will need to convert RTF to the HTML format that you will need to send "rich" emails http://stackoverflow.com/questions/439301/convert-rtf-to-html – Matthew Lock Dec 08 '15 at 01:56
  • Possible duplicate of [Generating HTML email body in C#](http://stackoverflow.com/questions/886728/generating-html-email-body-in-c-sharp) – TFD Dec 08 '15 at 03:43

3 Answers3

1

A code snippet below. From RichTextBox in your application you need to convert to html

 MailMessage mail = new MailMessage();
    mail.To = "joymon@gmail.com";
    mail.From = "from@company.com";
    mail.Subject = "PoC html mail";
    mail.BodyFormat = MailFormat.Html;
    mail.Body = "this is first line.<br><b>bold</b>"; //Get from RTB in html format.
    SmtpMail.SmtpServer = "<smtp server>";
    SmtpMail.Send( mail );
Joy George Kunjikkuru
  • 1,495
  • 13
  • 27
0

Mail messages are formatted with HTML, so you first need a way of turning your rtf to html. Fortunately that has already been answered.

Once you have your html content, you need to create a mail message and assign the html content as the mail body. Here is another question that shows how to do that.

Community
  • 1
  • 1
Fede
  • 3,928
  • 1
  • 20
  • 28
0

A code snippet below.

        MailMessage mail = new MailMessage();
        mail.To = "to@mail";
        mail.From = "from@mail";
        mail.Subject = "Colored Text Emails";
        mail.BodyFormat = MailFormat.Html;
        mail.Body = " <font size='3' color='red'>This is some text!</font> <br/><font size='2' color='blue'>This is some text!</font><br/><font face='verdana' color='green'>This is some text!</font> ";
        SmtpMail.SmtpServer = "<smtp server>";
        SmtpMail.Send(mail);