CDOSys and query attachments

  • Hi everyone,

    I am having a bit of a problem when it comes to adding the results from a stored procedure to an email using CDOSYS. I am able to send emails perfectly using the code provided from the msdn website and have been searching the web now for 2 days to see how to add an attachment using the provided code and all I can come across is that the following line needs adding to my "sendMail" stored procedure:

    EXEC @hr = sp_OAMethod @iMsg, 'AddAttachment', 'http://someuri/picture.gif'

    Is it possible to use the CDOSYS mail sending procedure and add the results from an existing stored procedure as an attachment to the email? If so please please please can someone guide me on what I need to do because I am getting fed up of reading the same thing over and over again about being able to add attachments from the local drives and url's.

    Thank you in advance

    Arif

    😀

  • Have you tried using xp_Sendmail?

    Hope this helps,
    Rich

    [p]
    [/p]

  • Hi rdouglass,

    my understanding is that the xp_sendmail sp would require "SQLMail" to be configured which depends on an Outlook client being configured and installed on the SQL server and the SQLServerAgent service would need to be started using the username for the Outlook mailbox. Or am I getting this completely wrong?

    Ideally I would like to steer clear of configuring the "SQLMail" functionality due to this reason. (Unless I have completely missed the point somewhere.)

    Thanks for your reply.

    Arif

  • Hi Arif,

    You're correct in that xp_Sendmail does have quite a few dependencies, I've not used CDOSYS before and thought that xp_Sendmail might be a viable alternative for you.

    Rich

    Hope this helps,
    Rich

    [p]
    [/p]

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

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