Hi, I tried several things sending email pragmatically, but get an error:

code here:
using System.Net;
using System.Net.Mail;
private void SendEmailOutlook(string toAddress, string fromAddress, string subject, string messageText, bool isHtmlMessage, string username, string password)
{
MailAddress from = new MailAddress(fromAddress);
using (SmtpClient client = new SmtpClient("smtp.gmail.com",465) { DeliveryMethod = SmtpDeliveryMethod.Network, EnableSsl = true, UseDefaultCredentials = false })
{
client.Credentials = new System.Net.NetworkCredential(username, password);
MailAddress to = new MailAddress(toAddress);
using (MailMessage message = new MailMessage(from, to) { IsBodyHtml = isHtmlMessage })
{
message.Subject = subject;
message.Body = messageText;
try { client.Send(message); } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
}
}
}
and then I call it:
SendEmailOutlook(target-email,"******@gmail.com", "subject text", " message text", false, "my-email-gmail.com", "My-Password");
Anyone can help me to figure this out.
Thanks.