简体   繁体   English

生成多个编码的HTML /文本电子邮件T-SQL

[英]Generating multiple encoded HTML/Text emails T-SQL

For my first question, I have your typical web e-com scenario where the user can order various products and then receive confirmation emails. 对于我的第一个问题,我有一个典型的网络电子商务场景,用户可以订购各种产品,然后收到确认电子邮件。 I've been doing a lot of searching on the best way to send emails for this application, and I am hoping someone can point me in the right directions. 我一直在为这个应用程序发送电子邮件的最佳方式进行大量搜索,我希望有人可以指出我正确的方向。

I can send plain text confirm emails from either the app or the database just fine, but now I want to change things up by creating a series of HTML template to use when sending emails. 我可以发送纯文本确认来自应用程序或数据库的电子邮件,但现在我想通过创建一系列HTML模板来更改内容,以便在发送电子邮件时使用。 There will be multiple HTML templates, and multiple email contents. 将有多个HTML模板和多个电子邮件内容。 When the user makes an order, the order is recorded in the database, which then determines, via stored proc, the type of product/order, and selects the appropriate template file name, email content and replaces all the key text with user/order information. 当用户下订单时,订单被记录在数据库中,然后数据库通过存储过程确定产品/订单的类型,并选择适当的模板文件名,电子邮件内容并用用户/订单替换所有关键文本信息。

At the same time, I'd like the email encoded with the text version as well, so I can send out one email containing both types, and be done. 同时,我也喜欢用文本版本编码的电子邮件,因此我可以发送一封包含这两种类型的电子邮件,然后完成。

Is it possible to do this in SQL Server 2008 R2, or should I send the content information back to the app and then send the email? 是否可以在SQL Server 2008 R2中执行此操作,还是应该将内容信息发送回应用程序然后发送电子邮件? The problem I am worried about with the latter is, it may cause some delay on the site as it communicates back and forth with the database. 我担心后者的问题是,它可能会导致网站出现一些延迟,因为它与数据库来回传递。

Further, I'd like to switch to Amazon SES, which is easily used with .Net, but I have not yet been able to set up with SQL 2008 R2, so I'm not sure if this is a mistake on my side, or a compatibility issue. 此外,我想切换到易于与.Net一起使用的Amazon SES,但我还没有能够设置SQL 2008 R2,所以我不确定这是否是我的错误,或兼容性问题。

The basics: Application: .Net 4.0 Database: SQL 2008 R2 基础知识:应用程序:.Net 4.0数据库:SQL 2008 R2

The key requirement here is sending the HTML and text versions of the message in the same email. 这里的关键要求是在同一封电子邮件中发送消息的HTML和文本版本。 SQL Server database mail doesn't support sending multi-part MIME messages - if you want to do this, you will need to send the mail from your application. SQL Server数据库邮件不支持发送多部分MIME邮件 - 如果要执行此操作,则需要从应用程序发送邮件。

Command reference for sp_send_dbmail - note that the @body_format parameter can be either HTML or text - not both. sp_send_dbmail命令参考 - 请注意@body_format参数可以是HTML或文本 - 而不是两者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM