C
ChrisP1980
Guest
Hello!
I have researched the web on how to send e-mails via gmail through vb.net or asp.net code. Although I tried to follow the examples there it still does not work. What am I missing? Here is my code:
Public Sub SendMail(ToAddress As String, Subject As String, Body As String)
Dim tmpMail As New MailMessage
Dim tmpSMTP As New SmtpClient(_SMTPAddress) '_SMTPAddress = "smtp.gmail.com"
With tmpMail
.From = New MailAddress(_From) '_From = GMail user name and e-mail address
.To.Add(ToAddress)
.Subject = Subject
.Body = Body
End With
With tmpSMTP
.Credentials = New System.Net.NetworkCredential(_From, _Password) 'GMail user name and e-mail address, password
.Port = _SMTPPort 'SMTPPort = 587
.EnableSsl = True
End With
Try
tmpSMTP.Send(tmpMail)
Catch
MsgBox("eMail cannot be sent.")
End Try
End Sub
Thank you in advance!
Christian
Continue reading...
I have researched the web on how to send e-mails via gmail through vb.net or asp.net code. Although I tried to follow the examples there it still does not work. What am I missing? Here is my code:
Public Sub SendMail(ToAddress As String, Subject As String, Body As String)
Dim tmpMail As New MailMessage
Dim tmpSMTP As New SmtpClient(_SMTPAddress) '_SMTPAddress = "smtp.gmail.com"
With tmpMail
.From = New MailAddress(_From) '_From = GMail user name and e-mail address
.To.Add(ToAddress)
.Subject = Subject
.Body = Body
End With
With tmpSMTP
.Credentials = New System.Net.NetworkCredential(_From, _Password) 'GMail user name and e-mail address, password
.Port = _SMTPPort 'SMTPPort = 587
.EnableSsl = True
End With
Try
tmpSMTP.Send(tmpMail)
Catch
MsgBox("eMail cannot be sent.")
End Try
End Sub
Thank you in advance!
Christian
Continue reading...