24小时后自动发送邮件 [英] send mail automatically after 24 hours
本文介绍了24小时后自动发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
24小时后自动发送邮件.
send mail automatically after 24 hours.
推荐答案
您可以通过数据库尝试此代码.
您需要SSIS每隔一段时间调用存储过程.
请检查此存储过程(我从这里获得了它:http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_21944312.html):
You can do this by your DataBase try this code.
You need SSIS to call a stored procedure every period of time.
Please check this for the stored procedure (I got it from here: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_21944312.html):
CREATE PROCEDURE [dbo].[PROC_CDOMAILALERTS]
@From varchar(200),
@To varchar(200),
@ReplyTo varchar(200),
@Cc varchar(200),
@ArchiveId varchar(200),
@SMTPServer varchar(100),
@Subject varchar(200) = " ",
@Body varchar(4000) = " "
AS
BEGIN
Declare @iMsg int
Declare @hr int
Declare @ht int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)
--********************************************************************
--Set the ids to which Bcc should be sent
Set @ArchiveId = @ReplyTo + ',' + @ArchiveId
--************* Create the CDO.Message Object ************************
EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
--***************Configuring the Message Object ******************
-- This is to configure the Remote Server Name or IP address.
-- Replace MailServerName by the name or IP of your SMTP Server.
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', @SMTPServer
-- Save the configurations to the message object.
EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
-- Set the e-mail parameters.
EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
EXEC @hr = sp_OASetProperty @iMsg, 'ReplyTo', @ReplyTo
EXEC @hr = sp_OASetProperty @iMsg, 'Cc', @Cc
EXEC @hr = sp_OASetProperty @iMsg, 'BCc', @ArchiveId
EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
EXEC @ht = sp_OADestroy @iMsg
RETURN @hr
END
链接[ ^ ]
link [^]
希望此 [
Hope this[^] might help you.
这篇关于24小时后自动发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文