0

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);


        }
    }
}
Luv
  • 49
  • 3
  • 9
  • 3
    I hope you have not written here your real account and your real password – Steve Dec 17 '17 at 16:46
  • 1
    Did you check all the possible issues mentioned in [Sending email in .NET through Gmail](https://stackoverflow.com/q/32260/205233)? Specifically [Turn On Access for less secure apps in the gmail account](https://stackoverflow.com/a/32457468/205233)? – Filburt Dec 17 '17 at 16:48
  • no i didn't put my real user name and password. yeah, it looks like it could be someone's account password, so i changed it to xxxxxxxx. Didn't want people getting wrong idea. thanks, though. – Luv Dec 17 '17 at 17:28
  • Filburt, nice try. was hoping it would work, but it did not. thanks, though. – Luv Dec 17 '17 at 17:52
  • There's more to check at [How to send an email in .Net according to new security policies](https://stackoverflow.com/q/34851484/205233) – Filburt Dec 17 '17 at 21:54

0 Answers0