使用 C# 3.5 通过 Thunderbird 发送自定义电子邮件时如何在电子邮件正文中包含用户签名?

发布于 2024-12-21 19:49:33 字数 1093 浏览 6 评论 0原文

我们需要使用 C# 3.5 从桌面应用程序发送电子邮件。要求是使用 Thunderbird 发送新电子邮件,不是直接从我们的应用程序发送。因此,我们为新电子邮件设置某些属性,例如 emialfrom、emailto、主题、正文和邮件正文。通过代码附件,我们将其保存为 .eml 文件 &然后我们使用代码在 Thunderbird 中打开该 .eml 文件: 我们遵循的逻辑是:

MyEmailClass eml = new MyEmailClass();
eml.Subject = "subject";
eml.SetHtmlBody(" email body");
eml.From = "from";
email.AddTo = "[email protected]";
email.AttachmentPath = "attachmentpath";

email.SaveEml("myEmail.eml");

现在我们有了 .eml 文件和 .eml 文件。我们需要在 Thunderbird 中打开它,我们使用 System.Diagnostics.Process.Start 在 Thunderbird 中打开 eml 文件:

System.Diagnostics.Process.Start(thunderbird exe path,myEmail.eml path);

上面的工作正常,但是我们只有一个问题,当电子邮件在 Thunderbird 中打开

事实

1- 用户拥有与其帐户关联的有效签名。

2-我们正在使用 Thunderbird 8.0

3-我们正在使用 C# 3.5

4- Thunderbird 是用户系统上的默认电子邮件客户端。

We need to send email from our desktop application using C# 3.5. The requirement is to send the new email using the Thunderbird, not directly from our application. So we are setting certain properties for the new email like emialfrom, emailto, subject, body & attachments through code, we save it as an .eml file & then we open that .eml file in thunderbird using code:
The logic we are following is:

MyEmailClass eml = new MyEmailClass();
eml.Subject = "subject";
eml.SetHtmlBody(" email body");
eml.From = "from";
email.AddTo = "[email protected]";
email.AttachmentPath = "attachmentpath";

email.SaveEml("myEmail.eml");

So now we have the the .eml file & we need to open it in the Thunderbird, we are using System.Diagnostics.Process.Start to open the eml file in Thunderbird:

System.Diagnostics.Process.Start(thunderbird exe path,myEmail.eml path);

The above works fine, however we have just one issue, the sender signature is not shown when the email opens in the Thunderbird.

Facts:

1- The user has valid signature associated with his account.

2- We are using Thunderbird 8.0

3- We are using C# 3.5

4- Thunderbird is the default email client on users systems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

温柔一刀 2024-12-28 19:49:33

签名由电子邮件客户端在创建电子邮件正文时添加。由于您是通过代码创建电子邮件正文,因此您必须以编程方式插入签名。需要明确的是,您不一定要在用户的计算机上启动 Thunderbird,而是要启动与 .eml 文件扩展名关联的任何进程。如果您想包含来自 Thunderbird 的签名,您可以查看他们的任何 API 帮助,但它们看起来好像已经好几年没有更新了。您还可以为用户提供在应用程序中设置签名的选项。

Signatures are added by the email client when it creates the email body. Since you are creating the email body through code, you would have to programmatically insert the signature. Just to be clear, you are not necessarily launching thunderbird on the user's machine, you are launching whatever process is associated with the .eml file extension. If you want to include the singature from Thunderbird, you could look to see if any of their APIs help, but they look like they haven't been updated in years. You could also give your users the option of setting up their signature within your application.

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