gpt4 book ai didi

sql-server - 如何将一封电子邮件发送给多个收件人?

转载 作者:行者123 更新时间:2023-12-02 10:09:38 27 4
gpt4 key购买 nike

我有一个存储过程,可以向少数收件人发送电子邮件。在此,我想使用 @copy_recipients 发送给两个不同的收件人。但我收到语法错误。如何使这项工作有效?

存储过程代码

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'mail',
@recipients = @Mail1,
@copy_recipients = @Mail2;@Mail3,
@body =@body ,
@subject =@subject

最佳答案

您需要使用字符串连接在电子邮件地址之间添加 ;(分号):

DECLARE @copy_to varchar(max)= @Mail2+';'+@Mail3

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'mail',
@recipients = @Mail1,
@copy_recipients = @copy_to,
@body =@body ,
@subject =@subject

您可以阅读MSDN文章here

[ @recipients= ] 'recipients'

Is a semicolon-delimited list of e-mail addresses to send the message to. The recipients list is of type varchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_dbmail returns an error.

[ @copy_recipients= ] 'copy_recipients'

Is a semicolon-delimited list of e-mail addresses to carbon copy the message to. The copy recipients list is of type varchar(max). Although this parameter is optional, at least one of @recipients, @copy_recipients, or @blind_copy_recipients must be specified, or sp_send_dbmail returns an error.

关于sql-server - 如何将一封电子邮件发送给多个收件人?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40211104/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com