User home
Store
System help
Ask a question
Search help
Login
   Help system Content Search
Article content
Send Email via C# through Google Apps account
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("sender_email@domain.tld", "P@$$w0rD");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;

try {
    MailAddress
        maFrom = new MailAddress("sender_email@domain.tld", "Sender's Name", Encoding.UTF8),
        maTo = new MailAddress("recipient_email@domain2.tld", "Recipient's Name", Encoding.UTF8);
    MailMessage mmsg = new MailMessage(maFrom.Address, maTo.Address);
    mmsg.Body = "<html><body><h1>Some HTML Text for Test as BODY</h1></body></html>";
    mmsg.BodyEncoding = Encoding.UTF8;
    mmsg.IsBodyHtml = true;
    mmsg.Subject = "Some Other Text as Subject";
    mmsg.SubjectEncoding = Encoding.UTF8;

    client.Send(mmsg);
    MessageBox.Show("Done");
} catch (Exception ex) {
    MessageBox.Show(ex.ToString(), ex.Message);
}
© Copyright 2017 Doka management panel