귀하의 질문에 대답하기 전에, 나는 어떤을 게시와 같은 질문이 더 명확하게 당신을 요청하고 싶습니다 이 스크립트 또는 이미 직면 한 모든 오류에 대해 이미 작성한 스크립트를 사용하여 쿼리를 쉽게 작성할 수 있습니다.
다음은 요구 사항을 충족하는 데 도움이되는 SQL 스크립트입니다. 스크립트는 제대로 작동하는지 테스트합니다.
declare @EmailBody NVARCHAR(MAX);
declare @username VARCHAR(50) = 'Sean';
SET @EmailBody = N'<p style="font-family:arial; font-size:13px;">'+
'Hello:<br/><br/>'+
'Following program has been submitted by '+ @username +' at '+convert(varchar(50),getdate(),103)+ ' for your review.'+
'Please review the program and take further action.<br/></p>'+
'<table border="1" cellspacing="0" cellpadding="4" style="font-family: Arial; font-size: 11px;">' +
'<tr>
<td>Program No:</td>
<td>xxxxxxxxxxx</td>
</tr>
<tr>
<td>Description:</td>
<td>xxxxxxxxxxx</td>
</tr>
<tr>
<td>BUnit:</td>
<td>xxxxxxxxxxx</td>
</tr>
<tr>
<td>Program Type:</td>
<td>xxxxxxxxxxx</td>
</tr>
<tr>
<td>Product Line:</td>
<td>xxxxxxxxxxx</td>
</tr>';
--select @EmailBody
EXEC msdb.dbo.SP_SEND_DBMAIL
@recipients='add recepients here seperated by ; eg : [email protected];[email protected]',
@subject = 'Write email subject here',
@body = @EmailBody,
@body_format = 'HTML';