本文整理汇总了VB.NET中System.Web.Mail.SmtpMail类的典型用法代码示例。如果您正苦于以下问题:VB.NET SmtpMail类的具体用法?VB.NET SmtpMail怎么用?VB.NET SmtpMail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmtpMail类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DisplayUsage
' 导入命名空间
Imports System.Web.Mail
Namespace SendMail
Public Class usage
Public Sub DisplayUsage()
' Display usage instructions in case of error.
Console.WriteLine("Usage SendMail.exe <to> <from> <subject> <body>")
Console.WriteLine("<to> the addresses of the email recipients")
Console.WriteLine("<from> your email address")
Console.WriteLine("<subject> subject of your email")
Console.WriteLine("<body> the text of the email")
Console.WriteLine("Example:")
Console.WriteLine("SendMail.exe SomeOne@contoso.com;SomeOther@contoso.com Me@contoso.com Hi hello")
End Sub
End Class
Public Class Start
' The main entry point for the application.
Public Shared Sub Main(ByVal args As String())
Try
Try
Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
Message.To = args(0)
Message.From = args(1)
Message.Subject = args(2)
Message.Body = args(3)
Try
SmtpMail.SmtpServer = "your mail server name goes here"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
Console.WriteLine("0", ehttp.Message)
Console.WriteLine("Here is the full error message")
Console.Write("0", ehttp.ToString())
End Try
Catch e As IndexOutOfRangeException
' Display usage instructions if error in arguments.
Dim use As usage = New usage()
use.DisplayUsage()
End Try
Catch e As System.Exception
' Display text of unknown error.
Console.WriteLine("Unknown Exception occurred 0", e.Message)
Console.WriteLine("Here is the Full Error Message")
Console.WriteLine("0", e.ToString())
End Try
End Sub
End Class
End Namespace