Click here to Skip to main content
15,886,632 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I want to create a windows form application using c#,my task is to download the attachment sent by one particular sender(say abc),daily.I google'd nearly for 2days,but,all in vain.I tried using Pop3,it shows only the unread mails,that to in some random order,i do not understand why. Imap is also showing so many errors,all i need to do is download ONLY ONE attachment,daily from a mail sent by my customer(abc),pls help.
Posted

1 solution

There is no such thing as "downloading attachments". If some of the mail content is some Web links, then you may have something to download, but it would not be a part of a message.

Actually, the term "attachment" is highly misleading. Nothing is actually "attached" to the mail. Actually, all the mail content is just one solid block of plain text (possibly in one of Unicode UTFs or some other "encoding"), nothing else. Everything is embedded in that single block. What looks like "attachment" is actually a mail part, separated by text separators defined in the top-level header of content type. Those "parts" have their separate groups of headers, and content types (and also "dispositions") can be different for each part. If content of the part is "binary", it is still plain text, with content encoded as base64:
http://en.wikipedia.org/wiki/Base64[^].

You need to parse it all top to button. The format of all this is defined by the whole set of standards, so you would need to do a good amount of reading: http://en.wikipedia.org/wiki/E-mail#Message_format[^].

Instead, you can use some available parser. In particular, please read this tutorial: http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18[^].

Look at this open-source parser: http://mimeparser.codeplex.com/[^].

—SA
 
Share this answer
 
Comments
Dholakiya Ankit 28-Sep-13 7:41am    
Really good one it would be nice if you can provide gmail setup in a windows application some what source or link it will be alternate to his question mine 5++++++++++
Sergey Alexandrovich Kryukov 28-Sep-13 10:35am    
Thank you, but I don't know about gmail setup. As I understand OP used POP3 and was able to get mail already, so I assumed the problem was the attachments, specifically.
—SA
Dholakiya Ankit 29-Sep-13 23:18pm    
Yup you are right

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900