xp_sendmail - attaching files without specifying the filename

  • Hello all - is there a way of using xp_sendmail to attach a file without the need to specify the filename - i basically want to be able to send an attachment from a specific folder - this works fine when i specify the exact name of the file - however the filename will change on a daily basis - can i specify a wildcard as the file will always be a .txt file? and there will only ever be one file in the folder.

    any advice would be greatly appreciated

    Regards

    Tracy

  • Not directly - no you cannot use wildcards.

    You can however pass a variable in to the xp_sendmail proc, so simply determine the filename, store it into a variable @filename

    and then

    exec xp_sendmail

    @recipients = '...',

    @message = '..'

    ..

    @attachments = @filename

    ..

    Also, as you've posted this in the SQL2005 forums, you should be using sp_send_dbmail. You can use the same method, but the parameter is @file_attachments.

    Kev

  • Hi Kev,

    Many thanks for the speedy reply - i am actually using sp_notify_operator - but i will give your solution a go

    many thanks

    Tracy

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

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