Click here to Skip to main content
13,189,811 members (59,832 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, I need to get unread emails from my inbox - to handle bounce-backs messages.
I don't need to get entire message. What I need is only: Subject and body only from unread e-mails.

I probably have to use IMAP, so could recommend me an "open-source" and good solution? so I can sell this software without any problems?

But, when smtp server don't support IMAP, I have to use POP3? That project will be good for that? Or maybe there is some other, better way ?

Thanks for help,


I've got an idea.
I can read how many messages are in inbox. So, I also can get the last one.
I can check if there is a bounce-back message in timer (every 5 minutes for example). I could get messages one by one, and check the date. If the message was sent before 5 min ago, i would break.
In that solution, I will not get all messages from an inbox every time. Is that good solution ?

The pseudo-code of my idea:
TIMER( Tick every 5minutes )
    loop(on inbox from end to begin)
        // If the message date is older then "5 minutes ago" break
        if (message date < DateTime.Now.AddMinutes(-5);)
            if (the subject is "Undelivered Mail Returned to Sender")
                // Here I will parse message so that I will know the addresse
                // And removie that addresse from my list.
Posted 14-Jul-11 3:15am
Updated 14-Jul-11 23:24pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

POP3 does not have the capability to track unread emails. If your server does not support IMAP you try to use outlook automation.

mnd017 14-Jul-11 11:16am
Thank you, but I found <a href="">here</a> sth like that:
POP3 Object:
- Download entire messages
- Download headers only
- UNIQUE Download messages/headers in PIPELINING mode - can boost performance up to 1000%
- UNIQUE Download messages with a single line of code (QuickDownloadMessage)

How do you explain that?
luisnike19 14-Jul-11 15:50pm
Yeah sure, there ar some components that can do that easier for you. I gave you free way to do it.
mnd017 14-Jul-11 17:14pm
I've updated question a little bit, could you tell mi if this is good idea?
luisnike19 14-Jul-11 17:53pm
That could work but I don't like that idea. That could cause a lot of time, let's think in a case when you always receive many e-mails by hour. You'll need to iterate each e-mail one by one and that will consume a lot of time and the process can be very slow. And then if a case you inbox has 100000 that will cause a lot of time to process just the last 5 min or something
mnd017 15-Jul-11 5:24am
But, I'm not sure you understand me. The largest amount of emails, which I will have to read is as many as has been delivered in 5 last minutes. In my question I add a pseudo-code of the algorithm.
skv_lviv 15-Jul-11 7:45am
Imagine another situation - you have lost connection for 1 hour, and something important arrived during this period?
So probably you should at least have not 5 minutes, but since the last time you successfully connected, or something like this
mnd017 15-Jul-11 8:06am
Yes, good point. So, I think that will be good solution, to solve handling bounce-backs over pop3 without outlook. Thank you.
luisnike19 15-Jul-11 9:43am
Your idea is not good. But anyway is your code. I hope it works for you.
mnd017 15-Jul-11 11:51am
I know it will works. But I would like to use possibly the best solution for dealing with bounce-backs emails with server without IMAP,only with POP3 and without outlook. Could you recommend me sth better? Would be great
luisnike19 21-Jul-11 17:43pm
Review this link, I hope it helps. It uses an exchange server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171016.2 | Last Updated 15 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100