ASP.NET.in.a.Nutshell.Second.Edition [Electronic resources]

G. andrew Duthie; matthew Macdonald

نسخه متنی -صفحه : 873/ 209
نمايش فراداده

SmtpMail

System.Web.Mail (system.web.dll)class

The SmtpMail class represents the SMTP Server. It includes a static Send( ) method that you can use to send email programmatically. There are two versions of the Send( ) method: one accepts a MailMessage object, and the other provides a quick and simple way to send an email message without creating a MailMessage instance (by specifying the sender''s email address, the recipient, the subject, and the body text as string parameters). Before sending a message, set the static SmtpServer with the name of IP address of the mail server (use "localhost" for the current computer).

public class 

SmtpMail { // Public Static Properties public static string

SmtpServer {set; get; } // Public Static Methods public static void

Send (MailMessage

message ); public static void

Send (string

from , string

to , string

subject , string

messageText ); }