I found the below snippet of code to send email. It doesn't work for me. It times out on send. Any ideas, anyone? It opens a blank window, then sits there and does nothing. I get no mail. Eventually it times out. Sorry for being verbose. Stackexchange has weird filters that won't allow me to post question unless I added more text to the body. It complained there was too much code and not enough text.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Net;
using System.Net.Mime;
using System.Threading;
using System.ComponentModel;
namespace TestHello
{
class Program
{
static void Main(string[] args)
{
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.Credentials = new NetworkCredential("klloil@gmail.com", "xxxxxxx");
smtpClient.EnableSsl = true;
MailMessage message = new MailMessage();
message.To.Add("kal@gmail.com");
message.Subject = "Password Manager Sync Account Created";
message.From = new MailAddress("xxxx@gmail.com");
message.Body = "My Email message";
smtpClient.Send(message);
}
}
}