Receiving email and downloading attachment through a C# Application

泪湿孤枕 提交于 2019-12-03 09:10:39

问题


I am trying to implement a WPF application which can receive the mails sent to a specific email address. The scenario is that, the user will send a PPT file as an attachment to a specific email address, and my WPF application will listen to this email and once it receives the email, it will download the attached file and saves it to the hard drive.

I looked a bit, but all I found was that the System.Net.Mail only supports sending emails through an application using System.Net.Mail.SmtpClient class. Can anyone suggest me how to do this in WPF and C#.

Thanks in advance!


回答1:


var client = new POPClient();
client.Connect("pop.gmail.com", 995, true);
client.Authenticate("admin@bendytree.com", "YourPasswordHere");
var count = client.GetMessageCount();
Message message = client.GetMessage(count);
Console.WriteLine(message.Headers.Subject);

A simple tip, that you can follow: http://www.joshwright.com/tips/sending-receiving-email-in-csharp




回答2:


You can use POP3 or IMAP to check for email messages and then process the email message for saving the attached .ppt file. Click here for a sample.



来源:https://stackoverflow.com/questions/19449161/receiving-email-and-downloading-attachment-through-a-c-sharp-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!