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# 应用程序接收电子邮件和下载附件
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01