简体   繁体   English

ASP.NET:如何使用POP3下载电子邮件附件?

[英]ASP.NET: How to download email attachments with POP3?

I am building an email receiving website. 我正在建立一个电子邮件接收网站。 I can read the email with the help of code used in Code Project, but I can't download email attachments. 我可以在Code Project中使用的代码帮助下阅读电子邮件,但无法下载电子邮件附件。

Can anyone tell me how to download email attachments using POP3? 谁能告诉我如何使用POP3下载电子邮件附件?

Thank you! 谢谢!

In one of my projects I used a commercial server component: aspNetPOP3 . 在我的一个项目中,我使用了一个商用服务器组件: aspNetPOP3 It does of the "difficult" things (MIME stuff). 它处理“难”的事情(MIME东西)。 Works very well for me. 对我来说效果很好。 Saving an attachment is very easy using that library, for example: 使用该库保存附件非常容易,例如:

POP3 pop = new POP3("127.0.0.1","dave@blah.com", "mypassword" );

pop.Connect();
MimeMessage msg = pop.GetMessage(1);

//save attachments to a directory
msg.SaveAttachments( "c:\\temp\\mydirectory\\", true );

pop.Disconnect();

When you send an email with an attachment, that file is encoded as base64 and included into your message. 当您发送带有附件的电子邮件时,该文件被编码为base64并包含在您的消息中。 So, if you already get your email message, you already got your attachment. 因此,如果您已经收到电子邮件,那么您已经拥有附件。 Now it's just to decode it. 现在只是解码它。

If you can provide more details on how far did you get, we'll can provide more information to help you to solve this issue. 如果您可以提供更多的详细信息,我们将提供更多信息来帮助您解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM