I'm writing in the hope that you will help me. Today I'm going to develop a mail application using vb.net, for this I wrote the code given below.
This code throws the exception ("SMTP Exception")
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