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

查看:46
本文介绍了通过 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# 应用程序接收电子邮件和下载附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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