Sending email in ASP.NET
Sending mail in ASP.NET is simple! You just create a message and then call the SmtpMail’s static send method:
MailMessage message = new MailMessage();message.To = "me@email.com";message.From = "me@email.com";message.Subject = "An email from helen";message.Body = "Hello Helen. From Helen.";SmtpMail.Send(message);
If you need to talk to a non-local server, that’s not really much more difficult. You just specify a SmtpServer address in the SmtpMail object before you send:
SmtpMail.SmtpServer = "mail.myserver.com"; SmtpMail.Send(message);
If your SMTP server requires authentication, just specify your username and password with the following fields in your message object before you send it:
message.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;message.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "myusername";message.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "mypassword";
References:







Comments