VS.NET 2010 (and above) Users Click Here   

HOMECONTACT PRODUCTS DOWNLOADS PURCHASE TESTIMONIALS FORUMS COMPANY CONTACT
Home
Products
Downloads
Purchase
Licensing
Licensing FAQ
Software Updates
Support Forums
Testimonials
Feature Requests
Guarantee
About Us
Contact Us
Hosting Companies
Privacy Policy
   
Shopping Cart


Search

Sending Email through Gmail using aspNetEmail

by Dave 2. March 2011 03:42

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

 

Downloading email using aspNetIMAP from Gmail

by Dave 2. March 2011 02:51


aspNetIMAP can easily fetch email from Gmail. To do this you must do the following:

a) Configure IMAP access in Gmail
b) Download the AdvancedIntellect.Ssl.dll from www.advancedintellect.com/download.aspx
c) Use aspNetIMAP over SSL at port 993 to connect.

Lets discuss this below.

Configure IMAP access in Gmail

Before you can access email, you must first configure IMAP in Gmail. To do this, log into Gmail, and click on the settings tab. You should see something similar to what is below. Basically, you want select "Enable IMAP".


Download the AdvancedIntellect.Ssl.dll
Once you have IMAP configured in Gmail, you need to download the AdvancedIntellect,Ssl.dll plugin to use with aspNetIMAP. You can download the dll from:
http://www.advancedintellect.com/download.aspx
Gmail only allows you to connect over IMAP using SSL. The  AdvancedIntellect,Ssl.dll allows you to do this.

Use aspNetIMAP over SSL at port 993 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.

Once that is done, the following code example will get you started. This example simply downloads the message count from your inbox, and loops through the headers of the individual messages.


C#

IMAP4 imap = new IMAP4( "imap.gmail.com" );

//create and load the ssl socket
AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket();
imap.LoadSslSocket( ssl );

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


//rest of the IMAP properties
imap.Port = 993;
imap.Username = "MyAccount@gmail.com";
imap.Password = "MyPassword";

//any logging for troubleshooting
imap.Logger = new IMAPLog();
imap.Logger.Path = "c:\\imap.log";
imap.Logger.Overwrite = true;

imap.Connect();

imap.Login();


//get the message count
MailFolder inbox = imap.SelectInbox();
int count = inbox.MessageCount;

//write it out
Response.Write( count.ToString() );

FetchClient fc = inbox.FetchClient;
//get the headers for each message (IMAP is a '1' based index. Start at '1'
for( int i=1;i<=count;i++)
{
	string headers = fc.Headers(i, IndexType.Ordinal );

	//do some work on the headers
	DoWork( headers );
}

imap.Disconnect();


VB.NET

Dim imap As New IMAP4("imap.gmail.com")

'create and load the ssl socket
Dim ssl As New AdvancedIntellect.Ssl.SslSocket()
imap.LoadSslSocket(ssl)

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


'rest of the IMAP properties
imap.Port = 993

'any logging for troubleshooting
imap.Logger = New IMAPLog()
imap.Logger.Path = "c:\imap.log"
imap.Logger.Overwrite = True

imap.Connect()


imap.Username = "MyAccount@gmail.com"
imap.Password = "MyPassword"
imap.Login()


'get the message count
Dim inbox As MailFolder = imap.SelectInbox()
Dim count As Integer = inbox.MessageCount

'write it out
Response.Write(count.ToString())

Dim fc As FetchClient = inbox.FetchClient
'get the headers for each message (IMAP is a '1' based index. Start at '1'
Dim i As Integer
For i = 1 To count
   Dim headers As String = fc.Headers(i, IndexType.Ordinal)
   
   'do some work on the headers
   DoWork(headers)
Next i

imap.Disconnect()


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


Thanks,
Dave Wanta

Downloading email using aspNetPOP3 from Gmail

by Dave 2. March 2011 02:15

aspNetPOP3 can easily fetch email from Gmail. To do this you must do the following:

a) Configure POP3 access in Gmail
b) Download the AdvancedIntellect.Ssl.dll from http://www.advancedintellect.com/download.aspx
c) Use aspNetPOP3 over SSL at port 995 to connect.

Lets discuss this below.

Configure POP3 access in Gmail
Before you can access email, you must first configure POP3 in Gmail. To do this, log into Gmail, and click on the settings tab. You should see something similar to what is below. Basically, you want select "Enable POP3 email".

You have a couple of different options. For example, when you connect over POP3 you can have Gmail behave like:
a) Keep the email in the Inbox
b) Mark the email as read, and kept in the Inbox
c) Archive the Message
d) Delete the Message

It's important to realize that in the POP3 protocol, there is only the Inbox. The POP3 protocol does not recognize any concept of mail folders. Thus, it's impossible to navigate or change to a different folder.

Download the AdvancedIntellect.Ssl.dll
Once you have POP3 configured in Gmail, you need to download the AdvancedIntellect,Ssl.dll plugin to use with aspNetPOP3. You can download the dll from:
http://www.advancedintellect.com/download.aspx
Gmail only allows you to connect over POP3 using SSL. The  AdvancedIntellect,Ssl.dll allows you to do this.

Use aspNetPOP3 over SSL at port 995 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.

Once that is done, the following code example will get you started. This example simply downloads the message count from your inbox, and loops through the headers of the individual messages.

C#

POP3 pop = new POP3( "pop.gmail.com" );

//create and load the ssl socket
AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket();
pop.LoadSslSocket( ssl );

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

//some logging in case we have any problems (not required)
pop.LogPath = "c:\\gmailpopop.log";

//rest of the POP3 properties
pop.Port = 995;
pop.Username = "MyAccount@gmail.com";
pop.Password = "MyPassword";

pop.Connect();

//get the message count as an example
int count = pop.MessageCount();

Response.Write( count.ToString() );

for( int i=0;i<count;i++)
{
	string headers = pop.GetHeaders(i);
	//Process the Headers using a custom method
	DoWork( headers );
}
pop.Disconnect();

VB.NET

Dim pop As New POP3("pop.gmail.com")

'create and load the ssl socket
Dim ssl As New AdvancedIntellect.Ssl.SslSocket()
pop.LoadSslSocket(ssl)

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

'some logging in case we have any problems (not required)
pop.LogPath = "c:\gmailpopop.log"

'rest of the POP3 properties
pop.Port = 995
pop.Username = "MyAccount@gmail.com"
pop.Password = "MyPassword"

pop.Connect()

'get the message count as an example
Dim count As Integer = pop.MessageCount()

Response.Write(count.ToString())

Dim i As Integer
For i = 0 To count - 1
   Dim headers As String = pop.GetHeaders(i)
   'Process the Headers using a custom method
   DoWork(headers)
Next i

pop.Disconnect()


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


Thanks,
Dave Wanta

 

 

 

 

Testimonial

You're a bloody legend, mate. "

Jack Fremantle Western Australia

Read more testimonials
ListNanny aspNetDNS aspNetEmail aspNetPOP3 aspNetMX IPMuncher aspNetMIME aspNetPING aspNetTraceRoute aspNetIMAP aspNetMHT