Hi Thearon,
I am using SmtpClient properties.
not SmtpServer.
code is something like this:
Imports System.Net.Mail
Public Class Form1
'Inside the formâs code window:
Public Sub SendAnEmail(ByVal MsgFrom As String, ByVal MsgTo As String, ByVal MsgSubject As String, ByVal MsgBody As String)
Try
' 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("127.0.0.1") ' = 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 Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendAnEmail("
[email protected]", "
[email protected]", "only testing for email sending", "nothing")
End Sub
End Class
renju