How to send email using dbmail to email using from same table

  • I have belwo codes which i want to convert to variable email IDs using same table.

    can some one help?

    use

    db

    go

    DECLARE @tableHTML NVARCHAR(MAX) ;

    SET @tableHTML =

    N'<H2>Dear User(USD)</H2>' +

    N'<table border="1">' +

    N'<tr><th>Column1</th><th>Column2</th>' +

    CAST ( ( SELECT td = [Column1],'',

    td = [Column2], ''

    FROM dbo.table1

    FOR XML PATH('tr'), TYPE

    ) AS NVARCHAR(MAX) ) +

    N'</table>'

    +N'

    Regards,</br>' +

    + N'XX'

    EXEC msdb.dbo.sp_send_dbmail @recipients='user@mail.com',

    @subject = 'Subject Line',

    @profile_name = 'MyProfile',

    @body = @tableHTML,

    @body_format = 'HTML' ;

  • It worked for me. I sorted out by myself.

  • please don't cross post. Original post: link



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply