Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# email
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 4:15am
Edited 15-Jul-11 0:24am

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 at 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 at 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 at 14-Jul-11 17:14pm
I've updated question a little bit, could you tell mi if this is good idea?
luisnike19 at 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 at 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 at 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 at 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 at 15-Jul-11 9:43am
Your idea is not good. But anyway is your code. I hope it works for you.
mnd017 at 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 at 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
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581

Advertise | Privacy | Mobile
Web02 | 2.8.150327.1 | Last Updated 15 Jul 2011
Copyright © CodeProject, 1999-2015
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