SQLserver发送邮件

SQLserver发送邮件,第1张

概述  --server 配置 sp_configure 'show advanced options', 1 go RECONFIGURE go sp_configure 'SQL Mail XPs', 1 go RECONFIGURE go sp_configure 'Database Mail XPs', 1 go RECONFIGURE go --1 基本配置ファイルを作成 EXECUTE m  

--server 配置
sp_configure 'show advanced options',1
go
RECONfigURE
go
sp_configure 'sql Mail XPs',1
go
RECONfigURE
go

sp_configure 'Database Mail XPs',1
go
RECONfigURE
go

--1 基本配置ファイルを作成
EXECUTE msdb.dbo.sysmail_help_profile_sp
--2 アカウントを作成
EXECUTE msdb.dbo.sysmail_help_account_sp ;
--3 基本配置ファイルとアカウント結合し順番を指定
EXECUTE msdb.dbo.sysmail_help_profileaccount_sp
--4 既定のアカウントを指定
EXECUTE msdb.dbo.sysmail_help_principalprofile_sp ;
--5 システムパラメータを指定
EXECUTE msdb.dbo.sysmail_help_configure_sp ;

 

exec dbo.sp_send_dbmail
@profile_name='myMail',
@recipIEnts='XXX@163.com',
@subject='メールテスト',
@body='hello'

exec dbo.sp_send_dbmail
select * from sysmail_log
select * from sysmail_sentitems

 

use master
go
exec sp_configure 'show advanced options',1
go
reconfigure
go
exec sp_configure 'Database mail XPs',1
go
reconfigure
go

--1 基本配置ファイルを作成
EXECUTE msdb.dbo.sysmail_help_profile_sp '1','fan'
--2 アカウントを作成
EXECUTE msdb.dbo.sysmail_help_account_sp ;
--3 基本配置ファイルとアカウント結合し順番を指定
EXECUTE msdb.dbo.sysmail_help_profileaccount_sp
--4 既定のアカウントを指定
EXECUTE msdb.dbo.sysmail_help_principalprofile_sp ;
--5 システムパラメータを指定
EXECUTE msdb.dbo.sysmail_help_configure_sp

exec msdb.dbo.sysmail_add_profile_sp 'fan',''

EXECUTE msdb.dbo.sysmail_add_account_sp
    @account_name = 'fan_mail',
    @email_address = 'xxx@dl.cn',
    @display_name = 'fan',
    @mailserver_name = 'mail.dl.cn',
    @username= 'xxx@dl.cn',
    @password ='fh13084178517',
    @use_default_credentials ='0';

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp 1,null,1,1

EXECUTE msdb.dbo.sysmail_add_principalprofile_sp 1,1

EXEC msdb.dbo.sp_send_dbmail
 @profile_name = 'fan',
@recipIEnts = 'xxx@dl.cn',
@subject = 'myTest',
@query = 'select * from test.dbo.a',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'a.txt',
@body='my love,hhhhh'

exec msdb.dbo.sp_send_dbmail
select * from msdb.dbo.sysmail_log
select * from msdb.dbo.sysmail_sentitems

select * from sysmail_log
select * from sysmail_sentitems

EXEC msdb.dbo.sp_send_dbmail
 @profile_name = 'fan',
@copy_recipIEnts='xxx@163.com',
@blind_copy_recipIEnts ='xxx@vip.163.com',@subject = 'myTest',@file_attachments = 'c:\5.txt.txt;c:\a\5.txt.txt',@body='my love,hhhhh',@importance = 'High'

总结

以上是内存溢出为你收集整理的SQLserver发送邮件全部内容,希望文章能够帮你解决SQLserver发送邮件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/sjk/1180195.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-02
下一篇2022-06-02

发表评论

登录后才能评论

评论列表(0条)

    保存