﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » Updates and Information » StrataFrame Users Contributed Samples  » Sending mail through GMail SMTP server</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 02:34:59 GMT</lastBuildDate><ttl>20</ttl><item><title>Sending mail through GMail SMTP server</title><link>http://forum.strataframe.net/FindPost24574.aspx</link><description>If you ever have the need to send mail through a GMail account, this sample may save you a few minutes.  It isn't hard, but there are a few differences which require SSL and authentication.  &lt;br&gt;
&lt;br&gt;
[codesnippet]//-- Establish Locals&lt;br&gt;
SmtpClient smtp = new SmtpClient("smtp.gmail.com ", 587);&lt;br&gt;
MailMessage msg = new MailMessage("reply@somewhere.com", "to@somewhere.com");&lt;br&gt;
&lt;br&gt;
//-- Set the subject line&lt;br&gt;
msg.Subject = "Hello World";&lt;br&gt;
&lt;br&gt;
//-- Set the body (Plain text in this sample)&lt;br&gt;
msg.Body = "Here is the body of the message.";&lt;br&gt;
&lt;br&gt;
//-- Attach the file if necessary&lt;br&gt;
msg.Attachments.Add(new Attachment(pathAndFileName));&lt;br&gt;
&lt;br&gt;
smtp.EnableSsl = true;&lt;br&gt;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;&lt;br&gt;
smtp.UseDefaultCredentials = false;&lt;br&gt;
smtp.Credentials = new NetworkCredential("myemail@gmail.com", "mypassword");&lt;br&gt;
&lt;br&gt;
//-- Send the message&lt;br&gt;
smtp.Send(msg);[/codesnippet]</description><pubDate>Tue, 08 Sep 2009 09:58:43 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>