SmtpMail.Send 方法
定义
发送电子邮件。Sends an email message. 建议使用的替代项:System.Net.Mail。Recommended alternative: System.Net.Mail.
重载
| Send(MailMessage) |
使用在 MailMessage 类的属性中提供的参数发送电子邮件。Sends an email message using arguments supplied in the properties of the MailMessage class. 建议使用的替代项:System.Net.Mail。Recommended alternative: System.Net.Mail. |
| Send(String, String, String, String) |
使用指定的目标参数发送电子邮件。Sends an email message using the specified destination parameters. 建议使用的替代项:System.Net.Mail。Recommended alternative: System.Net.Mail. |
Send(MailMessage)
使用在 MailMessage 类的属性中提供的参数发送电子邮件。Sends an email message using arguments supplied in the properties of the MailMessage class. 建议使用的替代项:System.Net.Mail。Recommended alternative: System.Net.Mail.
public:
static void Send(System::Web::Mail::MailMessage ^ message);
public static void Send (System.Web.Mail.MailMessage message);
static member Send : System.Web.Mail.MailMessage -> unit
Public Shared Sub Send (message As MailMessage)
参数
- message
- MailMessage
要发送的 MailMessage。The MailMessage to send.
例外
无法发送邮件。The mail cannot be sent.
Send(MailMessage) 方法需要 Microsoft Windows NT、Windows 2000 或 Windows XP 操作系统。The Send(MailMessage) method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system.
示例
下面的示例演示如何使用通过 MailMessage 发送电子邮件 SmtpMail 。The following example shows how to use MailMessage to send an email message using SmtpMail.
MailMessage myMail = new MailMessage();
myMail.From = "from@microsoft.com";
myMail.To = "to@microsoft.com";
myMail.Subject = "UtilMailMessage001";
myMail.Priority = MailPriority.Low;
myMail.BodyFormat = MailFormat.Html;
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>";
MailAttachment myAttachment = new MailAttachment("c:\attach\attach1.txt", MailEncoding.Base64);
myMail.Attachments.Add(myAttachment);
SmtpMail.SmtpServer = "MyMailServer";
SmtpMail.Send(myMail);
Dim myMail As New MailMessage()
myMail.From = "from@microsoft.com"
myMail.To = "to@microsoft.com"
myMail.Subject = "UtilMailMessage001"
myMail.Priority = MailPriority.Low
myMail.BodyFormat = MailFormat.Html
myMail.Body = "<html><body>UtilMailMessage001 - success</body></html>"
Dim myAttachment As New MailAttachment("c:\attach\attach1.txt", MailEncoding.Base64)
myMail.Attachments.Add(myAttachment)
SmtpMail.SmtpServer = "MyMailServer"
SmtpMail.Send(myMail)
适用于
Send(String, String, String, String)
使用指定的目标参数发送电子邮件。Sends an email message using the specified destination parameters. 建议使用的替代项:System.Net.Mail。Recommended alternative: System.Net.Mail.
public:
static void Send(System::String ^ from, System::String ^ to, System::String ^ subject, System::String ^ messageText);
public static void Send (string from, string to, string subject, string messageText);
static member Send : string * string * string * string -> unit
Public Shared Sub Send (from As String, to As String, subject As String, messageText As String)
参数
- from
- String
电子邮件发件人的地址。The address of the email sender.
- to
- String
电子邮件收件人的地址。The address of the email recipient.
- subject
- String
电子邮件的主题行。The subject line of the email message.
- messageText
- String
电子邮件的正文。The body of the email message.
例外
Send(String, String, String, String) 方法需要 Microsoft Windows NT、Windows 2000 或 Windows XP 操作系统。The Send(String, String, String, String) method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system.
示例
下面的示例演示如何使用发送简单消息 SmtpMail 。The following example shows how to send a simple message using SmtpMail.
string from = "from@microsoft.com";
string to = "to@microsoft.com";
string subject = "UtilMailMessage001";
string body = "UtilMailMessage001 - success";
SmtpMail.SmtpServer = "MyMailServer";
SmtpMail.Send(from, to, subject, body);
Dim from As String = "from@microsoft.com"
Dim mailto As String = "to@microsoft.com"
Dim subject As String = "UtilMailMessage001"
Dim body As String = "UtilMailMessage001 - success"
SmtpMail.SmtpServer = "MyMailServer"
SmtpMail.Send(from, mailto, subject, body)