我有一个使用 sp_send_dbmail 发送电子邮件的 SQL Server 2008 存储过程。
我正在使用以下代码:
set @bodyText = ( select
N'Here is one line of text ' +
N'It would be nice to have this on a 2nd line ' +
N'Below is some data: ' +
N' ' +
N' ' +
field1 +
N' ' +
field2 +
N' ' +
N'This is the last line'
from myTable )
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'myProfile',
@recipients = @to,
@body = @bodyText,
@body_format = 'TEXT',
@subject = 'Testing Email' ;
我的myProfile设置为使用本地smtp服务器,结果会在c:\ inetpub \ mailroot \ queue中生成一个.EML文件。当我打开其中一个.eml文件时(唉-只有Outlook Express能够打开它们,在其他任何地方查看它们只会显示一个base64编码的blob),它似乎将结果呈现为HTML-因此我不确定问题是否出在客户端上。
我尝试将\n放入消息中,但没有起作用。如何发送具有换行符的纯文本,并验证最终结果是否正确?
顺便说一句,我实际上无法将邮件发送到真正的电子邮件客户端进行测试 - 企业网络受到限制。