简体   繁体   English

是否可以使用SQL数据库邮件通过URL通过HTML页面发送HTML页面,就像在VBScript中使用CDO.Message对象一样?

[英]Can I use SQL Database Mail to send an HTML page as a message via its URL, the same way you can with the CDO.Message object in VBScript?

I'm working on a project that uses an SQL trigger to fire off emails when certain fields are updated, and the emails need to be in HTML format with complex design, something that would be very difficult to pull off using the @body_format = 'HTML' command. 我正在开发一个项目,该项目使用SQL触发器在更新某些字段时触发电子邮件,并且电子邮件必须采用具有复杂设计的HTML格式,使用@body_format =' HTML”命令。 As it stands, the only articles I've found have been about formatting the body of the message using HTML in the SQL code, but I'm looking to reference a URL and send the corresponding page as an HTML body. 就目前而言,我发现的唯一文章是有关在SQL代码中使用HTML格式化消息正文的,但是我希望引用URL并将相应的页面作为HTML正文发送。

I know that there's a way in VBScript to generate an HTML page and send it as a message by referencing its URL by using the .CreateHTMLBody command on a CDO.Message object, and that's the kind of functionality I'm looking for in SQL. 我知道VBScript中存在一种方法,可以通过使用CDO.Message对象上的.CreateHTMLBody命令来引用HTML的URL来生成HTML页面并将其作为消息发送,这就是我正在SQL中寻找的功能。

I'm using Microsoft SQL Server Management Studio. 我正在使用Microsoft SQL Server Management Studio。

Short answer no.... Long answer yes :) 简短的回答不是。...简短的回答是:)

Ways to do it. 做到的方式。

1) If you build your page on the web then just store the html in a table and look it up. 1)如果您在网络上构建页面,则只需将html存储在表中并进行查找。 If it needs to change all of the time build the html in a template manner that you put some crazy text in certain locations ( @@FIRSTNAME@@ ) that you will REPLACE with your dynamic content and all of a sudden you are good to go and not too much difficult handling of the html. 如果需要始终更改,请以模板方式构建html ,然后在某些位置( @@FIRSTNAME@@ )放置一些疯狂的文本,以REPLACE动态内容,突然之间,您就可以开始使用了并没有太多困难的HTML处理。

2) Build a CLR with your VB code. 2)用您的VB代码构建CLR。 this is more complex but on a plus side you can also send your message directly from here through an SMTP gateway and I have had issues where DB mail has retried and sent way too many messages to public users so I don't use it for heavy emailing at all! 这比较复杂,但从正面来看,您也可以通过SMTP网关直接从此处发送消息,而我遇到了数据库邮件重试并向公共用户发送太多消息的问题,因此我不会将其用于繁重的工作完全用电子邮件发送!

3) Build a SSIS package and place your VB script inside a script task to generate the email, create a SQL agent job, then use tSQL to execute that job. 3)构建一个SSIS包,并将您的VB脚本放入脚本任务中以生成电子邮件,创建一个SQL代理作业,然后使用tSQL执行该作业。

4) Call your VBScript directly xp_CmdShell or some other method straight from the trigger. 4)直接从触发器中直接调用xp_CmdShell或其他方法来调用VBScript。 This one is definitely the scariest impact from a security perspective but if you lock down access and only allow for certain user(s) it is not so so bad...... Here is an article that I haven't read in full but looks to be very exhaustive on the subject. 从安全角度来看,这绝对是最可怕的影响,但是如果您锁定访问权限并仅允许某些用户访问,那就还不算太糟……这是我没有完整阅读的文章但在这个问题上看起来非常详尽。 https://www.simple-talk.com/sql/database-administration/the-posh-dba-solutions-using-powershell-and-sql-server/ https://www.simple-talk.com/sql/database-administration/the-posh-dba-solutions-using-powershell-and-sql-server/

Added benefit to using methods > 1. You can create a threaded application to send several thousand messages very quickly if needed! 使用方法>的另一个好处是:1.如果需要,您可以创建一个线程化的应用程序以非常快速地发送数千条消息! I literally send 2,000 messages from my DB server to Exchange server in under a minute because of a threaded clr..... 由于线程clr,我在一分钟内从我的数据库服务器向Exchange服务器发送了2000条消息。

暂无
暂无

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

相关问题 如何找到特定的 SQL Server 数据库邮件生成的消息的来源? - How can I find the source of a specific, SQL Server Database Mail-generated message? 如何将html / javascript值发送到sql,并将其返回到jsp中的同一页? - How can I send html/javascript values to sql and return it back to the same page in jsp? 您可以使用 SQL 为 HTML 网站制作数据库吗? - Can you use SQL to make a database for a HTML website? ORLite:为什么会出现错误消息“无法通过包找到对象方法“创建”……” - ORLite: Why do I get the error-message 'Can't locate object method “create” via package…' 我如何才能发送消息和接收消息的所有唯一用户 - How can I can all unique user whom I send message and receive message 如何查找已向特定用户发送消息给相同用户的用户数量。 的SQL - How can I find the amount of users that have sent a message to the same users as a specific user. SQL 如何从 Sql 查询中向 SQL 分析器写入消息? - How can I write a message to SQL profiler from Sql a query? 我可以在 xamp localhost 上使用 Swift Mailer 发送 email 消息吗 - Can I send email message using Swift Mailer on xamp localhost 为什么我无法连接到我的sql数据库? 我收到错误消息:“无法通过套接字连接到本地MySQL服务器” - Why can't I connect to my sql database? I get the error message: “Can't connect to local MySQL server through socket” 我可以从数据库发送邮件(通知到表中的电子邮件字段)添加到 SQL 表的所有新行 - Can I send mail from database(Notification to an email field in table) for all the new rows which are added to an SQL Table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM