SmtpMail.Send Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sends an email message. Recommended alternative: System.Net.Mail.
Overloads
Send(MailMessage) |
Sends an email message using arguments supplied in the properties of the MailMessage class. Recommended alternative: System.Net.Mail. |
Send(String, String, String, String) |
Sends an email message using the specified destination parameters. Recommended alternative: System.Net.Mail. |
Send(MailMessage)
Sends an email message using arguments supplied in the properties of the MailMessage class. 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)
Parameters
- message
- MailMessage
The MailMessage to send.
Exceptions
The mail cannot be sent.
The Send(MailMessage) method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system.
Examples
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)
Applies to
Send(String, String, String, String)
Sends an email message using the specified destination parameters. 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)
Parameters
- 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.
Exceptions
The Send(String, String, String, String) method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system.
Examples
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)
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기