Hi,
I am trying to send email using SMTP. The code works on one machine, however, failure message appears on the other. Any clue what could be the reason!! The code is as below:
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("
[email protected]")
'To is a collection of MailAddress types
MyMailMessage.To.Add("
[email protected]")
MyMailMessage.Subject = "gmail"
MyMailMessage.Body = "Test gmail email"
'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("
[email protected]", "abc")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MessageBox.Show("Email Sent")
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try
Enter your message below
Sign in or Join us (it's free).