none
Carriage returns in the message body using sp_send_dbmail

    Question

  • Hi everyone,

    I am trying to send an HTML email using sp_send_dbmail where the email body is based on a nvarchar field that contains carriage returns.

    The email sends correctly but the carriage returns appear as ?x0D and the text format is screwed up.

    Does anyone have any idea how to fix it

                SET @formatHTML = N'<H1>New Cost Down Project As Owner</H1>' + 
                    N'<table border="1">' + 
                    N'<tr><th>Project Number</th><th>Project Title</th>' + 
                    N'<th>Raised By</th><th>Other Person</th><th>Part Number</th><th>Project History</th>' + 
                    CAST ( ( SELECT td = ProjectNumber,       ''
                                    td = ProjectTitle, ''
                                    td = CreatedBy, ''
                                    td = ISNULL(CreatedSubUser,'.'), ''
                                    td = ISNULL(PartNumber,'.'), ''
                                    td = ISNULL(ProjectHistory,'.'), '' 
                              FROM dbo.#tmpOwnerEmail 
                              WHERE #tmpOwnerEmail.OwnerID = @OwnerID 
                              FOR XML PATH('tr'), TYPE  
                    ) AS NVARCHAR(MAX) ) + 
                    N'</table>' +  
                    N'<div><H5>Disclaimer: <font color="blue"></FONT></H5></div>' + 
                    N'<div><H5>This email was sent automatically. Please do not respond to it as the account is not monitored.</H5></div>'  
     

    Thanks

    Phil
    Friday, March 06, 2009 10:58 AM

All replies