SmtpMail.Send Method (MailMessage)
.NET Framework (current version)
Sends an e-mail message using arguments supplied in the properties of the MailMessage class. Recommended alternative: System.Net.Mail.
Assembly: System.Web (in System.Web.dll)
<AspNetHostingPermissionAttribute(SecurityAction.Demand, Level := AspNetHostingPermissionLevel.Medium)> <SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode := True)> Public Shared Sub Send ( message As MailMessage )
Parameters
- message
-
Type:
System.Web.Mail.MailMessage
The MailMessage to send.
| Exception | Condition |
|---|---|
| COMException | The mail cannot be sent. |
| PlatformNotSupportedException | The Send method requires the Microsoft Windows NT, Windows 2000, or Windows XP operating system. |
The following example shows how to use MailMessage to send an e-mail message using SmtpMail.
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)
.NET Framework
Available since 1.1
Available since 1.1
Show: