Migration von System.Web.Mail nach System.Net.Mail

Ohne Kommentar:

using System.Net.Mail;
//using System.Web.Mail;
namespace CodeTests
{
 class Program
  {
  static void Main()
   {
   //Neu mit System.Net.Mail
   MailMessage message = new MailMessage("from@local", "to@local","Subject","Body");
   SmtpClient smtp = new SmtpClient();
   smtp.Host = "localhost";
   smtp.Send(message);
   //Alt mit System.Web.Mail
   //MailMessage Message = new MailMessage();
   //Message.From = "from@local";
   //Message.To = "to@local";
   //Message.Subject = "Subjekt";
   //Message.Body = "Body";
   //SmtpMail.SmtpServer = smtphost;
   //SmtpMail.Send(Message);
  }
 }
}

This entry was posted in Informatik. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>