Email Alternate View

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
I copied the following code out of MSDN. I am trying to make the Alternate View email method work, but am having some difficulty.

I receive a "{"Illegal characters in path."}" error. ANy suggestions?

C#:
    // Construct the alternate body as HTML.
    string body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
    body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
    body += "</HEAD><BODY><DIV><FONT face=Arial color=#ff0000 size=2>this is some HTML text";
    body += "</FONT></DIV></BODY></HTML>";

    // Add the alternate body to the message.
    AlternateView alternate = new AlternateView(body, MediaTypeNames.Text.Html);//error here
    message.AlternateViews.Add(alternate);
 
Nevermind, I got it to work.

C#:
            string body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
            body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
            body += "</HEAD><BODY><DIV><FONT face=Arial color=#ff0000 size=2>this is some HTML text";
            body += "</FONT></DIV></BODY></HTML>";

            AlternateView alternate = AlternateView.CreateAlternateViewFromString(body,null,"text/html");
            message.AlternateViews.Add(alternate);
 
Back
Top