我遇到的问题是我有一个MIME编码的文件,其中包含所有相关的邮件信息(subject,from,to,...),并希望通过C#在定义的SMTP服务器上发送。
我查看了MailMessage类并搜索了一个解决方案,但我找不到合适的东西。你能帮助我吗?
谢谢, 的Matthias
答案 0 :(得分:0)
当前版本的标准.NET框架不支持它AFAIK。但是,您会在大多数第三方邮件组件中找到此类功能。
以下代码使用我们的Rebex Mail库。
using Rebex.Net; // Smtp class
using Rebex.Mail; // contains the MailMessage and other classes
// create an instance of MailMessage
MailMessage message = new MailMessage();
// load the message from a local disk file
message.Load("c:\\message.eml");
Smtp.Send(message, "smtp.example.org");
答案 1 :(得分:0)
您可以使用Mail.dll email component轻松完成此任务:
IMail email = new CreateFromEmlFile("c:\\email.eml");
using(Smtp smtp = new Smtp())
{
smtp.Connect("smtp.company.com");
smtp.Ehlo(HeloType.EhloHelo, "Mail.dll");
smtp.Login("user", "password");
smtp.SendMessage(email);
smtp.Close(false);
}
请注意,Mail.dll是我创建的商业产品。
答案 2 :(得分:-1)
单词“no”。
您必须解析文件,提取数据,并在MailMessage对象上设置各种属性。
如果您要从mime内容创建或加载MailMessage对象,则无法在框架中本地执行此操作。