Read Time3 Minute, 25 Second

In this article, I will explain you how to read email from POP3 server or read emails from POP3 server which require SSL. Although I have not developed my own library, I prefer to utilize the available resource.

Well, while being in the development, you have very limited time constraint to go and research on POP3 and then develop your own component.

It is sometime wise decision to go and do the Googling and find out your requirement.

After all we, as developer should “do smart work, not hardwork”.

Anyway, for those who have kind of requirement like reading emails from POP3 server from asp.net, reading email from email server in asp.net etc. Here is the article that you probably find it useful.

Well I had requirement in couple of project where I need to collect emails that are there in particular email’s Inbox. Earlier I was used to with component “Indy.Sockets” component, which really help me to achieve my task.

You may find it from here.

www.indyproject.org/

It is an open source socket library. It supports may protocols like SMTP, POP3, NNTP, HTTP, and many more.

Then in one of the module that I come to develop, I need to read Inbox of a Gmail account…!

Well as you know, Gmail requires SSL.

But the drawback with component is it does not support SSL.

So I discover Mailsystem.NET.

MailSystem is a suite of .NET components that provide users with an extensive set of email tools.

I will not explain more in detail on this, rather I will rather just explain how to integrate it and use it.

You can find more information from here..

http://www.agilecomponents.com/

Once you download it and extract it, you will require to do following steps..

1. Navigate to “Release” folder in extracted folder.
2. Find these DLLs: ActiveUp.Net.Mail.dll, ActiveUp.Net.Common.dll, ActiveUp.Net.Dns.dll, ActiveUp.Net.Pop3.dll.
3. Add reference of these DLLs into your project.

Hurray… are almost done with you configuration.

Now, you only just need to develop your script that fetched and read emails from POP3 server.

So for that, here is the readymade script for you J.

public string[] GetSenderEmailsFromPOPServer()

{

Pop3Client pop = new Pop3Client();

System.Collections.Generic.List emails = new System.Collections.Generic.List();

try {

// Connect to the pop3 client

pop.ConnectSsl(SMTPHost, Port, SMTPUserId, SMTPPass);

MessageCollection mc = new MessageCollection();

for (int n = 1; n <= pop.MessageCount; n++) {

Message newMessage = pop.RetrieveMessageObject(n);

//do your stuffs here using newMessage object.

}

} catch (Pop3Exception pexp) {

} finally {

if (pop.IsConnected) {

pop.Disconnect();

}

}

return emails.ToArray();

}

One important part in this script is object initialization.

// Connect to the pop3 client

pop.ConnectSsl(SMTPHost, Port, SMTPUserId, SMTPPass);

As per Gmail, you need to set:

Host: pop.gmail.com

Port: 995

As I told earlier, I want to read email from POP3 server that requires SSL in asp.net.

There are different overloaded constructors that you can use to connect to POP3 server from asp.net.

The library itself is very rich. You can achieve following functionality with POP3 server.

  • Read/Read email from POP3 server in asp.net with CRAM authentication.
  • Retrieve/Read email from POP3 server in asp.net asynchronously.
  • Retrieve/Read email from POP3 server in asp.net with secure connection, like SSL in Gmail.
  • Retrieve/Read only email count from POP3 server in asp.net.
  • Retrieve/Read only email header from POP3 server in asp.net.
  • Retrieve/Read full emails from POP3 server in asp.net.
  • Retrieve/Read full emails to a file from POP3 server in asp.net.
  • Hope this will be handy to your programming..

    Happy programming.


NOTE : Also visit www.dhanashree.com


If you are in need of any
Web Development feel free to Inquire us . Dhanashree Inc. Expertise in Asp.net Development, Php Development,
Website designing
, Open Source customisation. Dhanashree Inc can be our offshore development company /
outsourcing web development company, hire dedicated web programmers.


Above information is for knowledge sharing if you have problem / issue / suggestion please intimate us with details for proper and prompt action.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Close