0
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

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by hirenpatel53
0

A couple of things to check...
Is it in the junk folder of the receiving account?
Is there a non-delivery report in the mailbox of the "From" account?

0

there is no junk folder in google and spam folder is empty
it does not showing any thing it shows olly MsgBox that i specified in code at the end

if u know will u please tell me what name we have to need to pass in to host name

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.