I read this article before:
Configuring other mail clients
Sending Email with System.Net.Mail
How to use System.Net.Mail.SmtpClient via SSL and Authentication?
Well for accomplish that, first adjust your web.config...
<system.net>
<mailsettings>
<smtp>
<network host="smtp.gmail.com" port="587" username="youraccount@gmail.com" password="yourpassword" defaultcredentials="false">
</network>
</smtp>
</mailsettings>
</system.net>
You write a few lines...
MailMessage message = new MailMessage();
message.From = new MailAddress("sender@domain.com");
message.To.Add(new MailAddress("destination@domain.com"));
message.Subject = "The subject";
message.Body = "The content";
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Send(message);
And run it.
No comments:
Post a Comment