Imports System.Net.Mail Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sendMail As New Net.Mail.SmtpClient Dim userToken As New Object With sendMail .Host = "smtp.gmail.com" .Port = 465 'port use by gmail to send mail .Credentials = New Net.NetworkCredential("usrname", "password") .UseDefaultCredentials = False End With sendMail = New Net.Mail.SmtpClient("smtp.gmail.com") sendMail.SendAsync(tbFrom.Text, tbTo.Text, tbSubject.Text, tbBody.Text, userToken) End Sub End Class
I import system.net.mail, by right I can just write smtpClient, but VB.net complained "Type Expected" and forced me to write Net.Mail.SmtpClient
I enabled port in my gmail account so that I can send and receive mail user an email client. The above code failed to work, after I click on send button my message was not delievered.. I did not receive message in my hotmail mailbox.. Did I miss out something?
Btw what is usertoken?
This post has been edited by rakyomin: 07 October 2008 - 10:25 AM