public class GMail { public void SendMailFromGoogle() { MailMessage mail = new MailMessage(); mail.From = new MailAddress("sender@mail.com"); mail.To.Add("receiver@mail.com"); mail.Subject = "Email Subject"; mail.Body = "Email Body"; var attachment = new Attachment("C:\\path\\file.ext"); mail.Attachments.Add(attachment); SmtpClient smtp = new SmtpClient("smtp.gmail.com"); smtp.Port = 587; // Account Username: Usually your "from" email. // App Password: If your account has a 2 step verification, you must follow these instructions // to generate the password: https://support.google.com/accounts/answer/185833?hl=en. smtp.Credentials = new NetworkCredential("Account Username", "App Password") as ICredentialsByHost; smtp.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; smtp.Send(mail); } }