DBMail, SQL Agent, Maintenance Plans, and sending an attachment to a specific email list...

  • Hello -

    I have a process that I am trying to automate through SQL Server 2008 R2 via DBMail and SQL Agent/Maintenance Plans. I essentially want to write a package that is going to go out into my network file system (in various locations just depending on which day of the week it is), to create and send an email to a specific group of recipients, with a file attached, and a specific message subject in place (and in some cases - the body of the message must have something pasted inside as well).

    I think this is all possible through a combination of a maintenance plan, DBMail, and SQL Agent, but I wanted to see if anyone is currently doing this, and if so - do you have any examples (code, process, SSIS packages, etc) that you could share with me?

    Thank you,

    Rich Yarger

  • To do it easy way, I think you have to create multiple jobs for each set of recipients and schedule the job for specific day and in sp_send_dbmail you can give exact path of files

    @file_attachments=exact path

    I hope the file name will be same every time....

    Other way is to keep the list of keep list of email id, file path and day to send in a table. Create one job with complex code which will check for current day and will automatically populate the details from table to @file_attachments field and recipient email field in sp_send_dbmail to send out emails...

    I will prefer to go with 1st one, number of different email set is not large...

    ===========================================
    Better try and fail than not to try at all...

    Database Best Practices[/url]

    SQL Server Best Practices[/url]

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

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