17 VB.NET Articles - Send Email using Google SMTP in vb.net
Viewing Article

Current Rating :

Send Email using Google SMTP in vb.net

Saturday, February 12, 2011Posted by admin

Category:vb.Net Utilities
 

Here is small function which will allow you to send the emails programatically using any SMTP server or you can also use the Google SMTP server if you have a GMAIL account.



Function SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal strSubject As String, ByVal strBody As String) As Boolean
        Dim mailmsg As New System.Net.Mail.MailMessage()

        mailmsg.From = New MailAddress(strFrom)

        mailmsg.To.Add(strTo)

        mailmsg.Subject = strSubject

        mailmsg.IsBodyHtml = True

        mailmsg.Body = strBody

        mailmsg.Priority = System.Net.Mail.MailPriority.Normal

        Dim client As New System.Net.Mail.SmtpClient()

        client.Host = "smtp.gmail.com"
        client.Port = "587"

        client.Credentials = New System.Net.NetworkCredential("youremailid@gmail.com", "Yourpassword")

       ' client.EnableSsl = True

        Dim userstate As Object = mailmsg



        client.Send(mailmsg)
        Return True
    End Function





Replace the email id and the password with your own  gmail id and your gmail password

Hits:254      Current Rating :      No Of Ratings: 220      AuthorName: admin
  

Comment#23      Friday, February 11, 2011          Posted by Sumeet Singh

 
Hi this site is really great

Comment#29      Wednesday, April 04, 2012          Posted by Mike Hansen

 
The number of Saturdays or Sundays will always be 4 or 5. After much gnashing of teeth, here is the single formula that gives you the answer. iif(Today.AddDays(-Today.Day).Subtract(Today.AddDays(-Today.Day).AddMonths(-1).AddDays(4-Today.AddDays(-Today.Day).AddMonths(-1).DayOfWeek)).TotalDays/7 >

Comments

Your Name  
 
Your Email( will not appear on page)  
Your Comments