User Tools

Site Tools


snippets:smtp

Assembly (reference)

System

Using directive

using System.Net.Mail;

Code: send an Email

For details: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

SmtpClient client = new SmtpClient("SMTP mail server name or IP goes here");
 
// (do not use ';', this was used in previous API )
String to          = "Email recipients go here [',' separated]";
String from        = "Sender Email goes here"; 
 
MailMessage message = new MailMessage(from, to);
message.Subject     = "Email title goes here";
message.Body        = "Body text goes here";
client.Credentials  = CredentialCache.DefaultNetworkCredentials;
 
client.Send(message);
snippets/smtp.txt · Last modified: 2015/07/26 14:19 by jaap.dehaan