+1 vote

How can you toggle bold face in a message created with Mailbuilder? Example: I want to know the Name of the person.

by

1 Answer

+1 vote

You need to create an HTML email, as plain text emails don't contain any formatting information. For that you just need to use MailBuilder's Html property.

MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("alice@mail.com", "Alice"));
builder.To.Add(new MailBox("bob@mail.com", "Bob"));
builder.Subject = "This is an HTML email";

builder.Html =  "This is <strong>in bold</strong>.";

IMail email = builder.Create();

// Send the message
using (Smtp smtp = new Smtp())
{
    smtp.Connect("server.example.com");   // or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password");

    var result = smtp.SendMessage(email);

    smtp.Close();
}

Additionally MailBuilder will automatically convert your HTML to plain text, so both plain text version and html (formatted) versions are present in the email message, and the receiver can choose which on to use (this is the default behavior of almost all email programs).

by (279k points)
...