通过C#应用程序接收电子邮件并下载附件 [英] Receiving email and downloading attachment through a C# Application

查看:152
本文介绍了通过C#应用程序接收电子邮件并下载附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个WPF应用程序,该应用程序可以接收发送到特定电子邮件地址的邮件。方案是,用户将发送PPT文件作为特定电子邮件地址的附件,我的WPF应用程序将收听此电子邮件,并且一旦收到电子邮件,便会下载附件并将其保存到硬盘驱动器。

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.

我看上去有点,但是我发现的是 System.Net.Mail 仅支持通过以下方式发送电子邮件使用 System.Net.Mail.SmtpClient 类的应用程序。谁能建议我如何在WPF和C#中做到这一点。

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#.

预先感谢!

推荐答案

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);

一个简单的技巧,您可以遵循:
http://www.joshwright.com/tips/sending-receiving-email-in-csharp

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

这篇关于通过C#应用程序接收电子邮件并下载附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆