0
我在寫信,希望你能幫助我。今天我要開發一個使用vb.net的郵件應用程序,爲此我編寫了下面給出的代碼。發送郵件失敗:SMTP異常
此代碼拋出異常(「SMTP異常」)
Public Function SendAnEmail(ByVal MsgBody As String)
Try
Dim MsgFrom As String = "[email protected]"
Dim MsgTo As String = "[email protected]"
Dim MsgSubject As String = "claim Report"
' Pass in the message information to a new MailMessage
Dim msg As New Net.Mail.MailMessage(MsgFrom, MsgTo, MsgSubject, MsgBody)
' Create an SmtpClient to send the e-mail
Dim mailClient As New SmtpClient("219.64.91.90") ' = local machine IP Address
' Use the Windows credentials of the current User
mailClient.UseDefaultCredentials = True
' Pass the message to the mail server
mailClient.Send(msg)
' Optional user reassurance:
MessageBox.Show(String.Format("Message Subject ' {0} ' successfully sent From {1} To {2}", MsgSubject, MsgFrom, MsgTo), "EMail", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Information)
' Housekeeping
msg.Dispose()
Catch ex As FormatException
MessageBox.Show(ex.Message & " :Format Exception")
Catch ex As SmtpException
MessageBox.Show(ex.Message & " :SMTP Exception")
End Try
End Function
您能否顯示異常請-e.g. 550我們不會中繼等 – StuartLC 2010-08-04 04:47:50
發送郵件失敗:SMTP異常 – 2010-08-04 05:12:01