View Single Post
  #5 (permalink)  
Old September 7th, 2009, 09:26 PM
phuc2583 phuc2583 is offline
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks for replying me and this is the whole my code.
I think there is something wrong on that so Can you help me how can i fix it and work fine.
it work but when i check my email box so i can not receive any letter from submit form.
Shared Function GMailSend(ByVal mailFrom As MailAddress, ByVal mailTo As MailAddress, ByVal strSubject As String, ByVal strContent As String, Optional ByVal CCaddress As String = "", Optional ByVal BCCaddress As String = "") As Boolean
Dim mail As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
Dim kq As Boolean
mail.From = mailFrom
mail.To.Add(mailTo)
mail.Subject = strSubject
mail.Body = strContent
mail.IsBodyHtml = True
mail.BodyEncoding = System.Text.Encoding.UTF8
mail.ReplyTo = mailFrom
If CCaddress.Length > 7 Then mail.CC.Add(CCaddress)
If BCCaddress.Length > 7 Then mail.Bcc.Add(BCCaddress)

Dim credential As System.Net.NetworkCredential = New System.Net.NetworkCredential("username@nhatrang.co m", "password")
Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("smtp.gmail.com")
smtp.Credentials = credential
smtp.UseDefaultCredentials = False

smtp.EnableSsl = True
smtp.Port = 587 'also tried 587,465, 25
smtp.Host = "smtp.gmail.com"
Try
smtp.Send(mail)
kq = True
Catch ex As Exception
kq = False
End Try
Return kq
End Function

Thanks for all thing.
Best Regards,
Phuc Hoang

Last edited by phuc2583; September 7th, 2009 at 09:34 PM..