下面是从SQL Server2005内部运行的T-SQL代码。我正在寻找添加一个“回复”头,以便任何回复都会去“回复”地址,而不是发件人地址。是的,我知道如何在数据库邮件中设置它,但我只想在现有的解决方案中添加一些代码。我不想使用数据库邮件。
我正在寻找的是类似以下VB代码的东西,但我想要一个T-SQL版本...
Dim objMessage
objMessage = Server.CreateObject("CDO.Message")
objMessage.Fields("urn:schemas:mailheader:reply-to").Value = "SOME_OTHER_EMAIL_NOT_FROM"这是T-SQL代码...
EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value','smtp.mymailserver.com'
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusername").Value', 'username'
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value', 'password'
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value', '1'
EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL我不理解使用T-SQL等效项设置标头的语法。
发布于 2009-03-06 06:10:07
请改用SQL Server 2005's Database Mail功能。
https://stackoverflow.com/questions/617791
复制相似问题