Hello everyone,
I am writing the following program to send a message to my gmail box. There is no
exception, but I can not receive any email in my gmail inbox. Does anyone have any ideas
why?
[Code] MailMessage mailMsg = new MailMessage(); mailMsg.From = new MailAddress("[email protected]"); mailMsg.To.Add("[email protected]"); mailMsg.Subject = "Test subject 2"; mailMsg.IsBodyHtml = true; mailMsg.BodyEncoding = Encoding.UTF8; mailMsg.Body = "This email is sent from asp.net code"; mailMsg.Priority = MailPriority.Normal; // Smtp configuration SmtpClient client = new SmtpClient(); client.Credentials = new NetworkCredential("[email protected]",
"mypassword"); client.Port = 587; //or use 465 client.Host = "smtp.gmail.com"; client.EnableSsl = true; object userState = mailMsg; try { //you can also call client.Send(msg) // client.SendAsync(mailMsg, userState); client.Send(mailMsg); } catch (SmtpException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); }
return;[/Code]
thanks in advance,George