zoukankan      html  css  js  c++  java
  • sql发邮件

     1 DROP PROCEDURE USP_CheckProductCodeRepeatAndSendMail
     2 go
     3 ---检查商家是否有重复的商品编号,如果有则发送给系统配置中接收的用户邮箱
     4 CREATE PROCEDURE USP_CheckProductCodeRepeatAndSendMail
     5 AS
     6     BEGIN
     7         IF EXISTS ( SELECT  OrganizationId ,
     8                             ProductCode ,
     9                             COUNT(1) num
    10                     FROM    dbo.T_Product
    11                     GROUP BY OrganizationId ,
    12                             ProductCode
    13                     HAVING  COUNT(1) > 1 )
    14             BEGIN
    15 
    16                 DECLARE @recipients VARCHAR(MAX)
    17 
    18                 SELECT TOP 1
    19                         @recipients = [NodeName]
    20                 FROM    [dbo].[T_DicConfig]
    21                 WHERE   NodeCode = 'CheckProductCodeRepeatAndSendMail'
    22 
    23                 IF @recipients IS NULL
    24                     SET @recipients = '***@qq.com'
    25 
    26                     PRINT @recipients
    27 
    28                 EXEC msdb.dbo.sp_send_dbmail @profile_name = 'mail', -- sysname
    29                     @recipients = @recipients, -- varchar(max)
    30                     @copy_recipients = '', -- varchar(max)
    31                     @blind_copy_recipients = '', -- varchar(max)
    32                     @subject = N'商家有重复的商品编号', -- nvarchar(255)
    33                     @body = N'', -- nvarchar(max)
    34                     @body_format = 'text', -- varchar(20)
    35                     @importance = 'NORMAL', -- varchar(6)
    36                     @sensitivity = 'NORMAL', -- varchar(12)
    37                     @file_attachments = N'', -- nvarchar(max)
    38                     @query = N'SELECT  *', -- nvarchar(max)
    39                     @execute_query_database = '***', -- sysname
    40                     @attach_query_result_as_file = 0, -- bit
    41                     @query_attachment_filename = N'', -- nvarchar(260)
    42                     @query_result_header = 1, -- bit
    43            -- @query_result_width = 10, -- int
    44                     @query_result_separator = '|', -- char(1)
    45                     @exclude_query_output = 1, -- bit
    46                     @append_query_error = 1, -- bit
    47                     @query_no_truncate = 0, -- bit
    48                     @query_result_no_padding = 1, -- bit
    49                     @mailitem_id = 0, -- int
    50                     @from_address = '', -- varchar(max)
    51                     @reply_to = '' -- varchar(max)
    52                 PRINT 'sp_send_dbmail'
    53             END
    54         ELSE
    55             PRINT 'empty data'
    56     END
  • 相关阅读:
    Move site collections to a new database
    SharePoint 2010 Site Workflow
    Customizing the Server Ribbon
    [转]深入浅出之正则表达式
    asp.net中MD5加密写法代码
    asp.net中过滤非法字符防止SQL注入
    jQuery中ajax的使用方法
    gridview中用NewSelectedIndex获取选中的ID值
    GridView中得到选中的某行的ID值
    用javascript伪装链接地址状态代码
  • 原文地址:https://www.cnblogs.com/lizhanglong/p/5652842.html
Copyright © 2011-2022 走看看