mm.Subject = Subject.Text
'textboxmm.Body = Body.Text
'textboxmm.IsBodyHtml =
False Dim smtp As New Net.Mail.SmtpClientsmtp.Host =
"smtp.email.co.uk"smtp.Credentials =
New Net.NetworkCredential("sales@email.co.uk", "saxxxxxn")smtp.Send(mm)
End Sub
Email That Works!
Michael A. Riley
C# translation:
//import the System.Net/System.Net.Mail namespace:
using System.Net.Mail;
..
..
//some event example: button click:
MailMessage theMailMessage = new MailMessage("email@address.com", "to@someAddress.com");
theMailMessage.Subject = "Your subject";
theMailMessage.Body = "the body email message";
//to enable html formatting, uncomment this line:
//theMailMessage.IsBodyHtml = true; //by default its false
//add attachments:
theMailMessage.Attachments.Add(new MailAttachment("pathToFile"));
try
{
SmtpClient theSmtpServer = new SmtpClient("some.Smtp.Ip.Address");
theSmtp.Credientials = new NetworkCredential("your@emailAddress.com", "password");
theSmtpServer.Send(theMailMessage);
}
catch (SmtpException ex)
{
//handle the error
}