Quantcast
Viewing latest article 2
Browse Latest Browse All 10

Sending Email through Gmail using aspNetEmail

aspNetEmail can easily send email through Gmail. To do this, you must do the following:

a) Download the AdvancedIntellect.Ssl.dll from http://www.advancedintellect.com/download.aspx
b) Use aspNetEmail over SSL at port 587 to connect and send.

Lets discuss this below.

Download the AdvancedIntellect.Ssl.dll
To send email through Gmail, you need to do this over SSL. The AdvancedIntellect.Ssl.dll provides this functionality. It is a plugin that can be used with aspNetEmail.
You can download the dll from http://www.advancedintellect.com/download.aspx

Use aspNetEmail over SSL at port 587 to connect.
Once you've downloaded the dll, you can integrate it into your project.

If you are using VS.NET, import the dll into your application, and set a reference to it.

If you are not using VS.NET, you should be able to just copy the dll to your /bin directory.

Below is a simple code example that demonstrates sending the email through gmail.


C#

EmailMessage msg = new EmailMessage();

string userAccount = "MyAccount@gmail.com";
string password = "MyPassword";

//some basic properties
msg.Server = "smtp.gmail.com";
msg.Port = 587;
msg.Username = userAccount;
msg.Password = password;

msg.FromAddress = userAccount;
msg.To= "You@yourcompany.com";
msg.Subject = "This is my test email through gmail.";
msg.Body = "Put the body contents here...";

//any logging (not reqired) for troubleshooting
msg.LogPath = "c:\\temp\\email.log";
msg.Logging = true;

//create the ssl socket
AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket();
msg.LoadSslSocket( ssl, false);

//logging on the ssl socket
ssl.Logging = true;
ssl.LogPath = "c:\\ssl.log";

msg.Send();


VB.NET

Dim msg As New EmailMessage()

Dim userAccount As String = "MyAccount@gmail.com"
Dim password As String = "MyPassword"

'some basic properties
msg.Server = "smtp.gmail.com"
msg.Port = 587
msg.Username = userAccount
msg.Password = password

msg.FromAddress = userAccount
msg.To = "You@yourcompany.com"
msg.Subject = "This is my test email through gmail."
msg.Body = "Put the body contents here..."

'any logging (not reqired) for troubleshooting
msg.LogPath = "c:\temp\email.log"
msg.Logging = True

'create the ssl socket
Dim ssl As New AdvancedIntellect.Ssl.SslSocket()
msg.LoadSslSocket(ssl, False)

'logging on the ssl socket
ssl.Logging = True
ssl.LogPath = "c:\ssl.log"

msg.Send()

As always, if anyone has any questions, feel free to contact me over at the Contact Us web page.


Thanks,
Dave Wanta

 


Viewing latest article 2
Browse Latest Browse All 10

Trending Articles