发送不带附件的邮件没有问题,只要带附件就报错误。
消息 22051,级别 16,状态 1,第 0 行
附件文件 D:\Serial.txt 无效。
DECLARE @itemID INT
DECLARE @AttachFile nvarchar(max)
SET @AttachFile = 'D:\Serial.txt'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'sp_send_dbmail',
@recipients = '16986204@qq.com',
@body = '查询结果在附件中',
@subject = '查询结果',
@body_format ='HTML',
@mailitem_id = @itemID OUTPUT,
@file_attachments = @AttachFile
print @itemID
消息 22051,级别 16,状态 1,第 0 行
附件文件 D:\Serial.txt 无效。
DECLARE @itemID INT
DECLARE @AttachFile nvarchar(max)
SET @AttachFile = 'D:\Serial.txt'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'sp_send_dbmail',
@recipients = '16986204@qq.com',
@body = '查询结果在附件中',
@subject = '查询结果',
@body_format ='HTML',
@mailitem_id = @itemID OUTPUT,
@file_attachments = @AttachFile
print @itemID