actually i have used mail on vb.net windows forms
i have used this code for this
[code=vbnet]
Imports System.Net.Mail
'Inside the form’s code window:
Public Sub SendAnEmail(ByV al 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.MailMe ssage(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.UseD efaultCredentia ls = 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.M essageBoxButton s.OK, Windows.Forms.M essageBoxIcon.I nformation)
' 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[/code]
Then all that remains to do is create some calling code . This example uses a button click to send data that I type into four textboxes with self-explanatory names: (You can replace them with literal strings of your own)
[code=vbnet]
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
SendAnEmail(Fro mBox.Text, ToBox.Text, SubjectBox.Text , MsgBodyBox.Text )
End Sub[/code]
but it gives the error unable to find server 5.7.1 and mail sending is failed i
i have already configure iis and settings also smtp mail server but it can't work
when i have used on web application then it fine work so if you have any solution regarding this then plz help me
thanks in advance
i have used this code for this
[code=vbnet]
Imports System.Net.Mail
'Inside the form’s code window:
Public Sub SendAnEmail(ByV al 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.MailMe ssage(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.UseD efaultCredentia ls = 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.M essageBoxButton s.OK, Windows.Forms.M essageBoxIcon.I nformation)
' 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[/code]
Then all that remains to do is create some calling code . This example uses a button click to send data that I type into four textboxes with self-explanatory names: (You can replace them with literal strings of your own)
[code=vbnet]
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
SendAnEmail(Fro mBox.Text, ToBox.Text, SubjectBox.Text , MsgBodyBox.Text )
End Sub[/code]
but it gives the error unable to find server 5.7.1 and mail sending is failed i
i have already configure iis and settings also smtp mail server but it can't work
when i have used on web application then it fine work so if you have any solution regarding this then plz help me
thanks in advance
Comment