Send mail to more than 1 mail id through Account

  • Created an account with two mail id's (separted by ,). Need to check if the mail is working i.e. sending mails to both id's in case of job failure.. When tested using test mail and through SP, it requires the recepient id to send the mail to.. So how can i chk whether the mail would be sent to both the mail id's

  • the parameter @recipients for msdb.dbo.sp_send_dbmail expects a semicolon delimited list of recipients; there's no limit to the # of recipients, since it is a varchar(max) definition;

    so if you are storing multiple emails in a single field, if you replace the comma with a semicolon, you'd see multiple emails go through in a single email.

    declare @body1 varchar(4000)

    set @body1 = 'Sample Email from SQL2008 ' + CONVERT( VARCHAR( 20 ), GETDATE(), 113 ) +

    ' '

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name='gMail',

    @recipients='lowell@yourdomain.com; "SQL Oracle" <sqloracle@anotherdomain.com>; balasach82@domain.com',

    @subject = 'SQl 2008 email test',

    @body = @body1,

    @body_format = 'HTML',

    @query = 'SELECT top 3 * from sysobjects where xtype=''U''',

    @query_result_header = 0,

    @exclude_query_output = 1,

    @append_query_error = 1,

    @attach_query_result_as_file = 1,

    @query_attachment_filename = 'qry.txt',

    @query_result_no_padding = 1

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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