HowTo - Send Mails with GMail

Open the App.config or Web.config file and edit the smtpServiceConfiguration section.

<smtpServiceConfiguration
  hostname="smtp.gmail.com"
  port="587"
  username="GmailUsername"
  password="GmailPassword"
  senderName="SenderName"
  from="GmailEmailAddress"
  cc=""
  bcc=""
  redirection=""
  enableSsl="true"
  useDefaultCredentials="false" />

Example

var smtpWrapper = ServiceLocator.Current.Resolve<ISmtpService>();
smtpWrapper.Send("user@nowhere.com", "Subject...", "Content...");

Or

SmtpServiceHelper.Current.Send("user@nowhere.com", "Subject...", "Content...");

Alternative

var smtpWrapper = ServiceLocator.Current.Resolve<ISmtpService>();

using (SmtpClient smtpClient = smtpWrapper.GetSmtpClientInstance())
using (MailMessage mailMessage = new MailMessage("from@gmail.com", "user@nowhere.com")
{
    Subject = "Subject...",
    Body = "Content..."
})
{
    smtpClient.Send(mailMessage);
}