Result set as an email message?

  • Hello All,

    I have a DTS package which exports the result set to an excel sheet and email it to the users using SMTP Mail task. I'm wondering if I can achieve this by sending the result set in email message body instead of a spreadsheet. Please advise.

    Thanks,

    -Amith Vemuganti

  • not exactly what you're looking for, but my favorite way to email result sets is via Reporting Services subscriptions. very easy to read on mobile phones as well

  • I'm actually looking for my DTS package being able to send the result set, pulled by a SELECT statement inside the ExecuteSQL package, in an email with SMTP mail task to the users. I'd appreciate if some one could give me a solution or an idea on how I can do it.

    Thanks,

    -Amith Vemuganti

  • EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'ProfName',

    @recipients = '',

    @query = 'SELECT 1,1,1,1,1',---specify your select query here

    @subject = 'SUB',

    @attach_query_result_as_file = 0 ;

    The result of query will go in the body of the mail.

    -Vikas Bindra

  • vikas bindra (11/25/2009)


    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'ProfName',

    @recipients = '',

    @query = 'SELECT 1,1,1,1,1',---specify your select query here

    @subject = 'SUB',

    @attach_query_result_as_file = 0 ;

    The result of query will go in the body of the mail.

    Where is the Excel file being created here? The OP wanted an excel file to have the results and send that excel in email.


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Bru Medishetty (11/25/2009)


    vikas bindra (11/25/2009)


    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'ProfName',

    @recipients = '',

    @query = 'SELECT 1,1,1,1,1',---specify your select query here

    @subject = 'SUB',

    @attach_query_result_as_file = 0 ;

    The result of query will go in the body of the mail.

    Where is the Excel file being created here? The OP wanted an excel file to have the results and send that excel in email.

    I think he doesn't want the spread sheet. check his first post.

    Hello All,

    I have a DTS package which exports the result set to an excel sheet and email it to the users using SMTP Mail task. I'm wondering if I can achieve this by sending the result set in email message body instead of a spreadsheet. Please advise.

    Thanks,

    -Amith Vemuganti

    Either of us got it wrong:-)

    -Vikas Bindra

  • I am confused now...:-)


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Lets wait for his reply.:Whistling:

    -Vikas Bindra

  • Vikas/Bru, Thanks for responding!

    Yes. I don't want the result set in spread sheet or any other file. I want the result set to be sent in email message body. Unfortunately, I don't see sp_send_dbmail and xp_sendmail extended stored procedures in my msdb or master databases.

    Thanks,

    -Amith Vemuganti

  • sp_send_dbmail must be present in MSDB under system Stored procedures.

    To use this procedure to send mails first you need to configure Database Mail under the Management tab in SSMS.

    -Vikas Bindra

  • Not sure, whether the OP was using SQL 2000 or 2005 ?


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Bru Medishetty (11/26/2009)


    Not sure, whether the OP was using SQL 2000 or 2005 ?

    Yes..He has not mentioned...

    My reply stands for 2005 and 2008;-)

    Hey Bru, I checked you site...you have small but really good blogs...

    -Vikas Bindra

  • Thanks,

    You can suggest something..

    I am planning to introduce few more sections adding a section each month.

    Coming backto this thread, the OP posted the thread in DTS, hence expecting it to be 2000.


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Oops...my bad...I didn't notice that...I also now think it is 2000..

    You can write a blog on configuring DBMail 🙂 Again a small but helpful article.

    -Vikas Bindra

  • Would be glad, I shall let you know when I post it.


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

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

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