How can I extract data from a table to excel then email it as an attachment.I would bcp the data out in a delimited format and if it must be, import into a spreadsheet to send as an attachment...
...you could just bcp it out comma delimited and let the recipient import it into the spreadsheet to if possible...|||this needs to be automated. It is going to send out an email notifiying a user of a new entry in the database. the new data will be included in the email.|||Originally posted by tonyh
this needs to be automated. It is going to send out an email notifiying a user of a new entry in the database. the new data will be included in the email.
Use DTS to export to the excel file, and then have it email the user with the excel file attached, or put the excel doc in a shared location, make it a linked server, and update it with a sql statement.|||I suggest you can create an instance of MS EXCEL in a stored procedure using sp_OACreate.
Then transfer the data from the table to the excel object (Within the stored procedure itself)
Then inside the stored proc use xp_sendmail to send the excel file. But unfortunately xp_sendmail uses MAPI provider through either MS Exchange or MS Outlook.
Alternatively you can again use sp_OACreate to instantiate a third-party COM component (for example RKMAIL or JMAIL) and use the same for sending the excel file as an attachment to the mail.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment