Mail senden mit Authentifizierung unter .net 2.0
using System.Net.Mail;
string strBetreff = "Betreff";
string strNachricht = "Inhalt der Mail";
string strVon = "User@domain.de";
string strAn = "User@domain.de";
string strSmtpServer = "mail.domain.de";
string strUser = "User";
string strPasswort = "xxx";
MailMessage mail = new MailMessage();
MailAddress from = new MailAddress(strVon);
mail.To.Add(strAn);
mail.From = from;
mail.Subject = strBetreff;
mail.Body = strNachricht;
string host = strSmtpServer;
int port = 25;
SmtpClient client = new SmtpClient(host, port);
System.Net.NetworkCredential nc = new System.Net.NetworkCredential(strUser, strPasswort );
client.Credentials = nc;
client.Send(mail);
2 Kommentare zum Snippet