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# 应用程序接收电子邮件和下载附件


基础教程推荐
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 如果条件可以为空 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 从 C# 控制相机设备 2022-01-01
- 将数据集转换为列表 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01