Send Gmail using Dot NET
Hi, in my previous posts, I have posted how to send mail using the Java API. In this section, I would like to demonstrate on how to send mail using Dot NET.
Using Dot NET, it is equally easy to send mail. In this post I would use my Dot NET application to connect with Google's outgoing mail server (Google's SMTP server) and use that to forward my mail. (In my previous post, I've demonstrated on sending mail using my own SMTP server which ran on my machine. In this scenario, it will directly put the outgoing message into the Gmail's SMTP server)
You will be using mainly few Classes to get the job done.
System.Net.Mail.MailMessage
System.Net.NetworkCredential
System.Net.Security.SmtpClient
These classes will provide the basic methods to get the job done.
You will also be using System.Net.Mail.MailAddress class. (Though there is a way to get the job done without actually needing this.)
First of all, you need to import the namespaces.
using System....