Nein, natürlich kann die MailMessage-Klasse HTML Mails verschicken. Du musst einfach in deinem MailMessage-Objekt die Eigenschaft IsBodyHtml auf true setzen.
diese Klasse kann Text und HTML Mails verschicken. Hier ein Beispiel:
private static void SendEmail(IList<string> recipients, IList<string> ccRecipients, IList<string> bccRecipients, string subject, string body) { List<string> mailto = new List<string>(); List<string> mailcc = new List<string>(); List<string> mailbcc = new List<string>();
MailMessage mailMsg = new MailMessage(); mailMsg.IsBodyHtml = sendAsHTML;
if (sendAsHTML) // optional { body = "<html><head><title>Title</title></head><body style='font-size:10pt;font-family:Arial'>" + body + "</body></html>"; }
foreach (string recipient in recipients) { if (mailto.Contains(recipient) == false) { mailto.Add(recipient); mailMsg.To.Add(recipient); } }
if (ccRecipients != null) { // ... }
if (bccRecipients != null) { // ... }
// From MailAddress mailAddress = new MailAddress("sender@somewhere.net"); mailMsg.From = mailAddress;
// Subject and Body mailMsg.Subject = subject; mailMsg.Body = body;
// Init SmtpClient and send string SMTPServer = "smtp@somwhere.net"; int SMTPPort = 25;
SmtpClient smtpClient = new SmtpClient(SMTPServer, SMTPPort); smtpClient.Credentials = new System.Net.NetworkCredential("user", "pwd");
Sogar noch eine tolle Antwort. Ich werde in Zukunft etwas mit dem Akzeptieren warten... codekicker funktioniert ja echt toll, wenn man ne schnelle Lösung will.