All source code in .Net Ask a .Net Pro Discussion Forum Categories All jobs in .Net
SSL,Connects,smtpgmailcom,authenticate,valid,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
.Net Stats

 Code: 666,891. lines
 Jobs: 818. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login





Latest postings for .Net.
Click here to see a screenshot of this code!Extracting Complex Data From DB using DataGridWiew
By Marijan Ivicevic - Bakulic on 10/15

(Screen Shot)

SQL Backup/Restore using SMO
By Visual Soft Computers on 2/6


Click here to see a screenshot of this code!flexi grid
By maytel.mynt on 1/12

(Screen Shot)

Using Excel in VB2010 (VB10)
By Alberto Torres on 2/5


Click here to see a screenshot of this code!SermonNotes
By arifliminto86 on 2/5

(Screen Shot)

Click here to see a screenshot of this code!A.net Programm to add new database
By Rohit Kanugo on 2/5

(Screen Shot)

Access_Database _Add
By Rohit Kanugo on 2/4


Add new DataBase Through Coding for a IT Company
By Rohit Kanugo on 2/4


Click here to see a screenshot of this code!Numbert To Word Conversion Short and Simple Code
By Opal Raj Ghimire on 2/3

(Screen Shot)

Click here to see a screenshot of this code!Monopoly Game
By arifliminto86 on 2/1

(Screen Shot)

Click here to see a screenshot of this code!Write Text to File, Write Binary To File
By brandon teoh on 2/1

(Screen Shot)

Click here to see a screenshot of this code!Movable Resizable Runtime Controls VB2005 Version
By SC Project on 2/1

(Screen Shot)

Desktop Email Client
By Avinash Kumar Sharma on 1/30


Website Source Code Grabber
By Avinash Kumar Sharma on 1/30


Click here to see a screenshot of this code!Auto Scrolling Label Method (autoscrolling textbox)
By Kenny28 on 1/30

(Screen Shot)

EL-Bandido Time Monitoring System Daily Record
By Ian Formanes on 1/30


Click here to see a screenshot of this code!Weather
By Jsvnascar on 1/29

(Screen Shot)

Mini NetMeeting
By Ian Formanes on 1/28


EL-Bandido
By Ian Formanes on 1/27


Click here to see a screenshot of this code!RegionMaker
By silviu petre on 1/27

(Screen Shot)

calculations class
By silviu petre on 1/26


Click here to see a screenshot of this code!Introduction to ADO.NET(OLEDBCO NNECTION)
By jay celeste on 1/21

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Send mail with SmtpClient using Gmail SMTP Server

Print
Email
 
VB icon
Submitted on: 5/10/2006 1:52:04 AM
By: Bernardo Bicalho  
Level: Intermediate
User Rating: By 1 Users
Compatibility:C#

Users have accessed this code 17510 times.
 
author picture
(About the author)
 
     Connects to smtp.gmail.com, authenticate a valid gmail user account using SSL and sends an email. Regular SSL port 465 won´t work. You´ll have to use an alternate port, 587.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    //**************************************
    //     
    // for :Send mail with SmtpClient using 
    //     Gmail SMTP Server
    //**************************************
    //     
    You are using Gmail services. Read their license of agreement to make sure you won´t do anything they wouldn´t aprove.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Send mail with SmtpClient using
    //     Gmail SMTP Server
    // Description:Connects to smtp.gmail.co
    //     m, authenticate a valid gmail user accou
    //     nt using SSL and sends an email.
    Regular SSL port 465 won´t work. You´ll have to use an alternate port, 587.
    // By: Bernardo Bicalho
    //
    // Inputs:valid gmail user account
    valid gmail user password
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/vb/scripts/Sh
    //     owCode.asp?txtCodeId=4733&lngWId=10    //for details.    //**************************************
    //     
    
    MailMessage MailObj = new MailMessage();
    				MailObj.To.Add("to@to.com");
    				//MailObj.From = "GmailAccount@gmail.com";
    				MailObj.From = new MailAddress("GmailAccount@gmail.com","From");
    				//MailObj.Cc = "cc@cc.com";
    			
    MailObj.IsBodyHtml = true;
    	
    				MailObj.Priority = MailPriority.Normal ;
    			string sAttach = @"c:\yourpic.jpg";
    MailObj.Attachments.Add(new Attachment(sAttach));
    				MailObj.Subject = "Subject";
    				MailObj.Body = "<table><tr><td>Test</td></tr></table>";
    SmtpClient smtpcli = new SmtpClient("smtp.gmail.com", 587); //use this PORT!
    smtpcli.EnableSsl = true;
    smtpcli.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpcli.Credentials = new NetworkCredential("GmailAccount@gmail.com", "GmailAccountPassword");
    try
    {
    smtpcli.Send(MailObj);
    }
    catch (Exception ex)
    {
    throw new Exception(ex);}


Other 1 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/3/2007 3:24:36 AMCodeBased

Hi there...


Thank you for sharing about SmtpClient class.

I need to know if you know how to connect with the gmail through socket programming so that I can run RAW commands on their pop server?

Kind regards,
Amit
(If this comment was disrespectful, please report it.)

 
4/3/2007 7:59:41 AMJason Vetter

Hey Amit, Googles Pop3 server is no different from any other pop server. There are lots of POP3 client examples on this site.
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | .Net Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.