Ugh this is so frustrating. This code doesn't work for some reason...Can anybody help me fix it?
It doesnt even have an error. It sometimes says ERROR due to the catch statement but now it doesnt display anything just the console cursor thing blinks for ever...
Code:
class MainClass
{
public static void Main (string[] args)
{
MainClass mailman = new MainClass();
mailman.Mailer();
}
public void Mailer ()
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com",465);
mail.From = new MailAddress("myemail@gmail.com");
mail.To.Add("otheremail@gmail.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Credentials = new System.Net.NetworkCredential("myemail@gmail.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Console.WriteLine("SENT");
}
catch
{
Console.WriteLine("ERROR");
}
}
}
Comment