Receiving email and downloading attachment through a C# Application(通过 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);
一个简单的提示,您可以遵循:https://joshwright.com/tips/tips-sending-receiving-email-in-csharp/
A simple tip, that you can follow: https://joshwright.com/tips/tips-sending-receiving-email-in-csharp/
这篇关于通过 C# 应用程序接收电子邮件和下载附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过 C# 应用程序接收电子邮件和下载附件


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 输入按键事件处理程序 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01