本文整理汇总了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 [email protected];[email protected] [email protected] 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
开发者ID:VB.NET开发者,项目名称:System.Web.Mail,代码行数:49,代码来源:SmtpMail
注:本文中的System.Web.Mail.SmtpMail类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论