How to retrieve only new emails using POP3 protocol - pop3

I am using POP3 protocol to retrieve my emails in my .NET application. I need to read just new emails only but found in many blogs that it is not possible to retrieve just "unseen" or "new" mails using POP3. Is that true? If so, could you please help me understand how Outlook Express manages to get new mails using POP3?
Is there any way that I can flag the seen mails in the email server itself? Or please help me find out a way to retrieve new mails using POP3 protocol.

You have to store the UIDL of each email in a local database. When you want to check for new mail, you retrieve the UIDLs on the server and see if you have if already in your local database; if not, it's a new mail.
Outlook uses the same strategy, BTW (see this KB article).

As long as your mailbox doesn't keep a copy of the emails on the server then you are fine and don't have to code for this.
Normally when an email client access the emails from a POP3 box they are downloaded and removed from the server.
Exchange is a different thing entirely.
Cheers

Related

Mailbox/Email Hosting Service with an API

I'm trying to create an email service web app but I do not want to deal with mail servers.
I'm only interested in creating the front-end web interface.
The ideal situation would be when a new user signs up, I create a mailbox on said service.
I would also use the service to pull emails from mailboxes, write to these mailboxes ( email tags) and possibly use the same service to send mail.
The closest thing I could find was mailGun.com but at this time it stores mailbox passwords using plain text -_- . They stated that this will be resolved in the future.
I also looked at postmark and emailYak.
Anyone know of any other services ?
I'm using Qboxmail that provides API for Email Hosting:
http://www.qboxmail.com/it/documentazione/api-email-hosting
I've not used them, but how about context.io

How do I get E-mail folders from a Gmail.com POP server using VB.net

I have managed to:
Connect to Gmail.com POP server (pop.gmail.com) Port 995 using Socket methods (TcpClient) and POP3 Commands (USER, PASS, STAT)
Get successful response from Gmail.com POP server using POP3 (STAT) command to my VB.net application (+OK)
Retrieve E-mails list from my Gmail.com account
Read those E-mails in plain Text format using a Textbox control.
The problem is that i get all the E-mails from the whole account, means :
If the inbox folder has (90) E-mails, sent folder has (10) E-mails and trash folder has (10) E-mails, then i get (100) E-mails in my application and they are not categorized, means you can not tell which one of them from inbox and which one is from trash.
So, my question is:
Is there a way to retrieve these Folders separately in my VB.net application ?
No, at least not with POP3.
The POP3 protocoll does not offer things like folders. You should probably use the IMAP protocoll, then.

Storing selected emails from outlook in SQL Server by forwarding

This may not be possible but just wanted to see if anyone could point me in the right direction.
I am building a system that needs to store all corespondence between the company and each client.
Is it possible to forward an email from outlook to a certain email address that will then store this email in an SQL server.
Thanks for any help.
You can try this Outlook Add-on: www.geniusconnect.com
Link Sent Items Outlook Folder to your table and check "Auto Save" option. This will save sent items automatically to DB.
You could write an outlook add-on using .NET that inserts the contents of the e-mail into a SQL Server table and the sender information.
Try looking at it the other way around. Build your email in the database first, then have a separate process actually send out the emails. After every successful send, you mark database email record as "sent".
I recommend an asynchronous approach. As emails are to be sent, they are generated and stored in an EmailQueue table. Another process monitors the EmailQueue table and sends out the emails as it discovers them. This way any delay with the actual sending of email will not interfere with the process that is generating the emails to be sent.

How to retrieve LASTEST emails from a POP3 Server?

I was recently working on a project that involving connection to a POP3 Server. I was using this piece of C# from CodeProject(http://www.codeproject.com/Articles/6062/A-POP3-Client-in-C-NET), had complied it into a DLL and was using it in VB.NET.
I'd connected to my Hotmail Account (not many mails) and it seems to work just fine. After that, I connected to my GMail account... I started seeing errors!
POP3 is meant to fetch emails only from the Inbox. Even when I made my own program to cross-check the problem, I saw that when I requested for the number of messages, the GMail POP3 Server returned a value which is about 5 times less than the actual inbox size.
255 Emails in my Inbox?? Online it shows me 2,414 emails in my Inbox.
And secondly, my MAIN QUESTION is that how does one fetch the LATEST email from the POP3 Mailbox. What I've fetched here was an e-mail with ID 1! I want to fetch the top 20 emails (that were most recently delivered to the account)...
Is there any work around for how to fetch the LATEST email from the POP3 Server rather than the oldest emails? I've also tried to connect to the Hotmail POP3 Mail Server. Again a "RETR 1" command fetches me the oldest email and not the latest one! Any known work-around?
I think your question is answered here: "Incorrect message count using STAT command" http://groups.google.com/group/Gmail-Help-POP-and-IMAP-en/browse_thread/thread/8be2c0b2bf383c15/7c57310cd5b11fc9?pli=1
[Update on 2016-06-30: The above link will not necessarily work, demonstrating why link-only answers are frowned upon so...]
The messages are made available in batches. After retrieving a batch, re-connect to get the next batch. Repeat as required.
in AUTH, instead of using:
USER foo#gmail.com
use:
USER recent:foo#gmail.com
instead of using pop3 u can use imap ptotocol to retrive all mails from GMAIL inbox.

How To read Emails in vb.net 2005

How can I read Emails in vb.net 2005 (without Using Third Party Control). Please Any idea and source code Give to me.(Any Method)
First of all there are multiple protocols to retreive mail:
POP3, IMAP, etc...
I suggest you start by familiarizing yourself with the various
components that make up an e-mail system.
Mail Transfer Agent (Protocol: SMTP)
Mail Delivery Agent (Protocols: POP3, IMAP)
Mail User Agent (Outlook, Webmail, Thunderbird, your application)
Basically what you are trying to write is a Mail User Agent.
A mail user agent has to "fetch" the mails from a Mail Delivery Agent using
either POP or IMAP.
This means you will have to learn about these two protocols:
POP3 RFC: http://www.faqs.org/rfcs/rfc1939.html
IMAPv4 RFC: http://james.apache.org/server/rfclist/imap4/rfc2060.txt
Since e-mail communication happens using TCP/IP you will have to learn
how to use the classes in the System.Net.Sockets namespace.
Take a look at the TcpClient class: http://james.apache.org/server/rfclist/imap4/rfc2060.txt
Try to understand these concepts first and then I suggest you start out with POP3,
this protocol is quite easy. If you have problems then with very specific TcpClient code please update your question or post a new question.
Hope this sets you on the right track.
Assuming you want to connect to POP mailbox and download emails, I'm afraid it's not all that straightforward to do in VB.NET.
There is an extensive article on CodeProject but it looks like a fairly advanced.