Send a Simple Email with ASP.NET
First, we need to import the System.Web.Mail namespace:
<%@ Import Namespace="System.Web.Mail" %>
Sending the message is a matter of calling SmtpMail.Send() with the following arguments: sender, recipient, subject and body. For example, we'd send an email in C# like this:
string from = "sender@example.com"; string to = "recipient@example.com"; string subject = "Hi!"; string body = "How are you?"; SmtpMail.SmtpServer = "mail.example.com"; SmtpMail.Send(from, to, subject, body);
SmtpMail.SmtpServer lets you specify the mail server used to deliver your message.
No comments:
Post a Comment