Difference between revisions of "ASP.Net SMTP Example"

From Hostek.com Wiki
Jump to: navigation, search
(Created page with "Exampels for sending mail with ASP.Net ==C#== System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtpmailer.hostek.net", 25); smtpClient.DeliveryMetho...")
 
m
Line 1: Line 1:
Exampels for sending mail with ASP.Net
+
Examples for sending mail with ASP.Net
  
 
==C#==
 
==C#==

Revision as of 08:47, 30 December 2012

Examples for sending mail with ASP.Net

C#

System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("smtpmailer.hostek.net", 25);
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Timeout = 60000;
smtpClient.EnableSsl = false;

System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
mailMessage.From = new System.Net.Mail.MailAddress("from_address@hostek_example.com", "from_display_name");
mailMessage.To.Add("to_address@hostek_example.com");
mailMessage.Bcc.Add("bcc_address@hostek_example.com");

mailMessage.Subject = "Email Subject";
mailMessage.IsBodyHtml = false;
mailMessage.Body = "Email Body";
smtpClient.Send(mailMessage);

VB

Dim smtpClient As New System.Net.Mail.SmtpClient("smtpmailer.hostek.net", 25)
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
smtpClient.Timeout = 60000
smtpClient.EnableSsl = False

Dim mailMessage As New System.Net.Mail.MailMessage()
mailMessage.From = New System.Net.Mail.MailAddress("from_address@hostek_example.com", "from_display_name")
mailMessage.To.Add("to_address@hostek_example.com")
mailMessage.Bcc.Add("bcc_address@hostek_example.com")

mailMessage.Subject = "Email Subject"
mailMessage.IsBodyHtml = False
mailMessage.Body = "Email Body"
smtpClient.Send(mailMessage)