Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
If txtFromAddress.Text = "" Then
MsgBox("Please Enter From Address", MsgBoxStyle.Exclamation)
txtFromAddress.Focus()
Else
If txtToAddress.Text = "" Then
MsgBox("Please Enter To Address", MsgBoxStyle.Exclamation)
txtToAddress.Focus()
Else
If txtSub.Text = "" Then
MsgBox("Please Enter Subject", MsgBoxStyle.Exclamation)
txtSub.Focus()
Else
Dim mailmessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
mailmessage.From = New System.Net.Mail.MailAddress(txtFromAddress.Text.Trim())
mailmessage.To.Add(New System.Net.Mail.MailAddress(txtToAddress.Text.Trim()))
'mailmessage.ReplyTo
mailmessage.Priority = Net.Mail.MailPriority.High
mailmessage.Subject = txtSub.Text.Trim()
'mailmessage.Attachments.Add(new System.Net.Mail.Attachment("c:\temp.txt")
mailmessage.IsBodyHtml = False
mailmessage.Body = txtBody.Text.Trim()
'Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
'Dim smtpClient As New System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings("network"))
Dim smtpClient As New System.Net.Mail.SmtpClient("smtp.gmail.com", 587)
smtpClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis
Try
smtpClient.Send(mailmessage)
MsgBox("Mail Sended Succsesfuiiy to " + txtToAddress.Text + " ")
txtFromAddress.Text = ""
txtSub.Text = ""
txtBody.Text = ""
txtToAddress.Text = ""
Catch smtpExc As System.Net.Mail.SmtpException
Catch ex As Exception
ex.Message.ToString()
End Try
End If
End If
End If
End Sub
this is my code writen by ASP.NET and Vb.NET while cliching on button message box shows( MsgBox("Mail Sended Succsesfuiiy to " + txtToAddress.Text + " ") ) means application executes completly but the mail we sended is not receved by the recever we specified in to txtToaddress.text
according to me the host name i passed must be wrong and i dont know what name to be passed here so please help me