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

This is the whole my code that i want to do.

Shared Function SendMail(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 smtpClient As New SmtpClient()
Dim message As New MailMessage()
Dim kq As Boolean
'Try
'You can specify the host name or ipaddress of your server
'Default in IIS will be localhost gsmtp185-2.google.com |gsmtp147.google.com
smtpClient.Host = "gsmtp147.google.com"
message.From = mailFrom
message.To.Add(mailTo)
If CCaddress.Length > 7 Then message.CC.Add(CCaddress)
If BCCaddress.Length > 7 Then message.Bcc.Add(BCCaddress)
message.IsBodyHtml = True
message.BodyEncoding = System.Text.Encoding.UTF8
message.ReplyTo = mailFrom
message.Priority = MailPriority.High
'Message body content
message.Subject = strSubject
message.Body = strContent
'Send SMTP mail
smtpClient.Send(message)
kq = True
'Catch ex As Exception
kq = False
'End Try
Return kq
End Function