Re: Sending email problem by Gmail account
I do this a similar way. I tested the following code and it works fine:
Code:
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();
message.Body = "Hello, there!";
message.From = new MailAddress("noreply@mycompany.com");
message.Sender = new MailAddress("noreply@mycompany.com");
message.To.Add(new MailAddress("errorsatmycompany@gmail.com"));
message.Subject = "Hi!";
client.Credentials = new NetworkCredential("errorsatmycompany@gmail.com", "mypassword");
client.EnableSsl = true;
client.Port = 587;
client.Host = "smtp.googlemail.com";
client.Send(message);
It just uses the email accounts user name and password, but the From field in gmail always shows up as "me". Odd...
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
Bookmarks