当我已经将电子邮件作为字符串时,如何发送电子邮件?
实际上,我正在尝试发送一些模板电子邮件,以便我可以测试一些处理邮箱读取的组件。
我可以加载 Outlook 并发送几封电子邮件,但我正在寻找一种可以一次读取数千封电子邮件的解决方案,因此我需要批量发送这些模板来测试阅读代码。
当我说批量发送时...我有大约 10 到 15 个模板(各不相同),并且我想将每个模板发送大约 1,000 个副本到给定邮箱。
现在这就是症结所在...
我可以启动 SMTP 客户端的实例并声明一个新的 MailMessage
对象,然后使用 SMTP 客户端发送该对象...问题是我的电子邮件模板包含自定义标头信息,因此它不仅仅是 msg.Body = someText
然后设置“收件人”、“发件人”和“主题”字段的问题。
我不想花时间手动解析这些电子邮件,因为标头相当长,并且包含许多我稍后将处理的自定义值。
因此,如果我有 txt
或 eml
文件,如何将该原始文本发送到我的邮箱,以便我可以执行上述测试?
Effectively I'm trying to send some template emails so that I can test a few components that handle reading from mailboxes.
I could just load up outlook and send a couple of emails but I'm looking to find a solution that can read thousands of emails at a time so I need to bulk send these templates t test the reading code.
When I say bulk send ... I have about 10 to 15 templates (varies) and I want to send about 1,000 copies of each to the given mailbox.
Now here's th sticking point ...
I could just fire up an instance of the SMTP client and declare a new MailMessage
object then send that using the SMTP client ... the problem is that my email templates contain custom header info so its not just a matter of msg.Body = someText
and then setting the To and From and Subject fields.
I don't want to spend time manually parsing these emails because the headers are quite lengthy and contain a lot of custom values that I'll be working on later.
So if I have a txt
or eml
file how do I send that raw text to my mailbox so I can perform my afformentioned testing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道做到这一点的最好方法是使用 MailBee.NET 对象,该对象不是免费的,但您可以下载试用版: http://www.afterlogic.com/mailbee-net/email-components
那么您正在寻找的是这样的:
披露:我不为 AfterLogic 工作,但有些他们的工具提供了很大的帮助使用 Elastic Email (http://elasticemail.com)
The best way I know to do this is using MailBee.NET objects which are not free, but you can download a trial: http://www.afterlogic.com/mailbee-net/email-components
Then what you are looking for is something like this:
Disclosure: I don't work for AfterLogic, but some of their tools have been a big help with Elastic Email (http://elasticemail.com)
如果您有格式正确的 RFC822 消息,只需在 SMTP 事务的 DATA 阶段按原样传输它即可。在 Unix 上,它基本上只是
在某些 Linux 发行版上,
sendmail
未安装在 PATH 上;如果您自己无法做出一些有根据的猜测,请尝试/usr/lib/sendmail
或咨询您的特定发行版的论坛。If you have a well-formed RFC822 message, just transfer it as-is in the DATA phase of the SMTP transaction. On Unix, it's basically just
On some Linux distros,
sendmail
is not installed on the PATH; try/usr/lib/sendmail
or consult a forum for your particular distro if you cannot come up with a few informed guesses on your own.我搜索中出现的另一个是 Email Architect 的 EASendMail。与 MailBee.NET 一样,它不是免费的,但我找到了具体文档 显示您通过调用 SendRawMail 方法请求的功能。该示例是用 C++/CLI 编写的,但同样适用于用 C# 或 VB.NET 编写的代码。如果我最终使用试用版来测试它,我会在这里发布我的反馈。
Another one that came up in my search is EASendMail by Email Architect. Like MailBee.NET it's not free but I have found specific documentation that shows of the feature you are asking for by calling the SendRawMail method. That example is in C++/CLI but the same would apply to code written in C# or VB.NET. If I end up using trial to test it out I'll post my feedback here.