This article has been dead for over three months
You
using System;
using System.Net;
using System.Net.Mail;
namespace SendGmail
{
public class CSendGmail
{
public static bool SendMail(NetworkCredential cred, string strSubject, string strEmailTo, string strBody, string strFileAttach, ref string strError)
{
bool blnRetVal = true;
try
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
//
MailMessage msg = new MailMessage();
if (!string.IsNullOrEmpty(strFileAttach))
{
msg.Attachments.Add(new Attachment(strFileAttach));
}
msg.To.Add(strEmailTo);
msg.From = new MailAddress(cred.UserName);
msg.Subject = strSubject;
msg.IsBodyHtml = true;
msg.Body = strBody;
//msg->Priority = MailPriority::High;
cred.Domain = "";
smtp.Credentials = cred;
smtp.Send(msg);
}
catch (Exception exc)
{
blnRetVal = false;
strError = exc.Message;
}
return blnRetVal;
}
}
}