共用方式為


SmtpMail.Send 方法

定義

傳送電子郵件訊息。 建議的替代做法: System.Net.Mail

多載

Send(MailMessage)

使用 MailMessage 類別的屬性中提供的引數來傳送電子郵件訊息。 建議的替代做法: System.Net.Mail

Send(String, String, String, String)

使用指定目的地參數來傳送電子郵件訊息。 建議的替代做法: System.Net.Mail

Send(MailMessage)

使用 MailMessage 類別的屬性中提供的引數來傳送電子郵件訊息。 建議的替代做法: 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

例外狀況

無法傳送郵件。

Send(MailMessage) 方法需要 Microsoft Windows NT、Windows 2000 或 Windows XP 作業系統。

範例

下列範例示範如何使用 MailMessage 來傳送電子郵件訊息 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)

使用指定目的地參數來傳送電子郵件訊息。 建議的替代做法: 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

電子郵件寄件者的地址。

to
String

電子郵件收件者的地址。

subject
String

電子郵件訊息的主旨。

messageText
String

電子郵件訊息的內文。

例外狀況

Send(String, String, String, String) 方法需要 Microsoft Windows NT、Windows 2000 或 Windows XP 作業系統。

範例

下列範例示範如何使用 來傳送簡單的訊息 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)

適用於