Send an email using System.Web.mail.smtpmail, handle SMTP verification issues

xiaoxiao2021-03-06  68

Unable to set SMTPServer, set MailMessage.

http://systemwebmail.com/faq/3.8.aspx

Private subject (Sender As Object, e as system.eventargs) Dim Mail as new mailmessage () mail.to = "me@mycompany.com" mail.from = "You@yourcompany.com" mail.subject = "this is IS a test email. "mail.body =" Some text Goes here "mail.fields.add (" http://schemas.microsoft.com/cdo/configuration/smtpauthenticate "," 1 ") 'Basic Authentication Mail.fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "MY_USERNAME_HERE") 'set your username here mail.fields.add ("http://schemas.microsoft.com/cdo/configuration/ SendPassword "," super_secret ") 'set you password here smtpmail.smtpserver =" mail.mycompany.com "' Your Real Server Goes Here Smtpmail.send (Mail) End Sub 'Page_load

My code:

Imports SystemImports System.Web.mail

Namespace Sendmail

Public Class usage Public Sub DisplayUsage () 'Display usage instructions in case of error. Console.WriteLine ( "Usage SendMail.exe ") Console.WriteLine ( " the addresses The Email Recipients ") Console.Writeline (" Your Email Address ") console.writeline (" Subject of Your Email ") console.writeline (" the text of the email "console. WriteLine ("eXample:") Console.Writeline ("Sendmail.exe someone@contoso.com; somother@contoso.com me@contoso.com hi hello") End Sub End Classpublic Class Start 'The Main Entry Point for the Application. public Shared Sub Main (ByVal sTo As String, ByVal sFrom As String, ByVal sSub As String, ByVal sBody As String) Try Try Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage Message.To = STO Message.from = sfrom message.subject = sss message.body = SBODY

Message.fields.add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") Message.fields.add ("http://schemas.microsoft.com/cdo/configuration/sendusername "," jetz ") message.fields.add (" http://schemas.microsoft.com/cdo/configuration/sendpassword "," *** ")

Try SmtpMail.SmtpServer = "smtp.263.net" 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 ("0", "0", E.TOSTRING ()) end Try End Sub End Classend NamespaceModule Module1 Sub Main () 'Dim K As New Sendmail.usage' K.Displayusage () Dim M AS New Sendmail.Start M.Main ("Jetzwmx@126.com", "Jetz@263.net", "Hi", "Hello" Console .Readline () End Subend Module

转载请注明原文地址:https://www.9cbs.com/read-119554.html

New Post(0)