当我已经将电子邮件作为字符串时,如何发送电子邮件?

发布于 2024-12-28 12:17:27 字数 527 浏览 0 评论 0原文

实际上,我正在尝试发送一些模板电子邮件,以便我可以测试一些处理邮箱读取的组件。

我可以加载 Outlook 并发送几封电子邮件,但我正在寻找一种可以一次读取数千封电子邮件的解决方案,因此我需要批量发送这些模板来测试阅读代码。

当我说批量发送时...我有大约 10 到 15 个模板(各不相同),并且我想将每个模板发送大约 1,000 个副本到给定邮箱。

现在这就是症结所在...

我可以启动 SMTP 客户端的实例并声明一个新的 MailMessage 对象,然后使用 SMTP 客户端发送该对象...问题是我的电子邮件模板包含自定义标头信息,因此它不仅仅是 msg.Body = someText 然后设置“收件人”、“发件人”和“主题”字段的问题。

我不想花时间手动解析这些电子邮件,因为标头相当长,并且包含许多我稍后将处理的自定义值。

因此,如果我有 txteml 文件,如何将该原始文本发送到我的邮箱,以便我可以执行上述测试?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最好是你 2025-01-04 12:17:27

我知道做到这一点的最好方法是使用 MailBee.NET 对象,该对象不是免费的,但您可以下载试用版: http://www.afterlogic.com/mailbee-net/email-components

那么您正在寻找的是这样的:

            MailBee.Mime.MailMessage message = new MailMessage();
            message.LoadMessage(filestream);
            MailBee.SmtpMail.Smtp.QuickSend(message);

披露:我不为 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:

            MailBee.Mime.MailMessage message = new MailMessage();
            message.LoadMessage(filestream);
            MailBee.SmtpMail.Smtp.QuickSend(message);

Disclosure: I don't work for AfterLogic, but some of their tools have been a big help with Elastic Email (http://elasticemail.com)

傾旎 2025-01-04 12:17:27

如果您有格式正确的 RFC822 消息,只需在 SMTP 事务的 DATA 阶段按原样传输它即可。在 Unix 上,它基本上只是

sendmail -oi -t <file

在某些 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

sendmail -oi -t <file

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.

执笏见 2025-01-04 12:17:27

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文