Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

asp.net - Fail Sending Email Unable To Connect the Remote Server

im facing error when sending email. here is the error

Error Email Sending Failure

what is the actual error for this exception because i newbie in in this, by the way here is my code line:

 Try
                Dim SmtpServer As New SmtpClient()
                Dim mail As New MailMessage()

                SmtpServer.Credentials = New  _
                Net.NetworkCredential("test@gmail.com", "passwordexample")
                SmtpServer.EnableSsl = True
                SmtpServer.Port = 587
                SmtpServer.Host = "smtp.gmail.com"

                mail = New MailMessage()
                mail.From = New MailAddress("test@gmail.com")
                mail.To.Add("examplemail@gmail.com")
                mail.Subject = "Change Request Submitted"
                mail.Body = "Dear User, " & Environment.NewLine & Environment.NewLine & Environment.NewLine & Environment.NewLine & "One Notification have been submitted," & Environment.NewLine & "Please check the change request on the intranet application"

//ad this line the error SmtpServer.Send(mail)
                SmtpServer.EnableSsl = True
                MsgBox("Notification emailed successfully")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please see this answer...

Sending Email from Visual Basic

If you still can't send the email....

Have you enabled POP or IMAP in Gmail? Sign in to the Gmail web interface.Open the 'Forwarding and POP/IMAP' tab on your 'Settings' page, and configure IMAP or POP. After enabling this in Gmail, make sure you click 'Save Changes' so Gmail can communicate with your mail client.

If you have 2 step verification..

Get an Application-Specific Password Google will automatically generate a password that you will need only once, when you set up Google Mail on your mobile device or email software. You can easily generate a password for each device or email software you want to use.

Step 1: At the bottom of the 2-step verification screen, next to Application-specific passwords, click Manage application-specific passwords. The Authorized Access to your Google Account screen will open.

Step 2: On the Authorized Access to your Google Account screen, in the Name field, type in a name to help you remember what application you are using to access your account and click Generate password. You will then see a password which you will use to configure your mobile device or email software. Keep this screen open until you are ready to enter the password (see part 4, below). The password creation with the device name will show at the bottom. When you are done using the password, click Done.

Step 3: To set up a password for another device or email software, simply type in the name of it in the Name field and click Generate password. You will receive another password.

See more here...

http://www.oit.umass.edu/support/google-apps/configure-google-mail-email-software-mobile-devices


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...