dbTalk Databases Forums  

xp_sendmail attachment question

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss xp_sendmail attachment question in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
martino
 
Posts: n/a

Default xp_sendmail attachment question - 09-23-2004 , 12:13 PM






Hello there

I am trying to run xp_sendmail with an attachment.
I have two attachments file1.txt and file2.txt, but I'd
like implement in the xp_sendmail a condition where if
file1.txt does not exist still attaches file2.txt and send
the email

Here is the sql i wrote so far, and is not quite working
yet,

declare @msg varchar(2000)
declare @cr char(1)
set @cr = char(13)
set @msg = 'Check Income Statement and Balance Sheet to
confirm accuracy of the data load.'

print @msg

exec master..xp_sendmail
@recipients = 'jdoe (AT) msfot (DOT) com',
@message = @msg,
@attachments = case @echo_error
when true 'E:\WHC_Reject.log'
else 'E:\Load_Report.txt' end,

@subject = 'Daily data load'

any help is highly appreciated!!

thanks





Reply With Quote
  #2  
Old   
Peter A. Schott
 
Posts: n/a

Default Re: xp_sendmail attachment question - 09-23-2004 , 03:45 PM






Either have to use dynamic SQL to build your string out or use an ActiveX task
to build the string. Sounds as if you've got everything else set to do
dynamic sql. Something like:

DECLARE @sql varchar(4000)

SELECT @sql = 'exec master..xp_sendmail @recipients = ''jdoe (AT) msfot (DOT) com'',
@message = ''' + @msg + ''',
@attchments = ' +
CASE WHEN ....
END
+ ',
@subject = ''Daily data load'''

select @sql --to see what it looks like
exec @sql --if it looks good


You may need an extra set of quotes near the attachments option, but this
should get you started. I try to display my command when debugging something
like this. Makes it easier to figure out where I messed up my quotes. :-)

-Pete

"martino" <anonymous (AT) discussions (DOT) microsoft.com> wrote:

Quote:
Hello there

I am trying to run xp_sendmail with an attachment.
I have two attachments file1.txt and file2.txt, but I'd
like implement in the xp_sendmail a condition where if
file1.txt does not exist still attaches file2.txt and send
the email

Here is the sql i wrote so far, and is not quite working
yet,

declare @msg varchar(2000)
declare @cr char(1)
set @cr = char(13)
set @msg = 'Check Income Statement and Balance Sheet to
confirm accuracy of the data load.'

print @msg

exec master..xp_sendmail
@recipients = 'jdoe (AT) msfot (DOT) com',
@message = @msg,
@attachments = case @echo_error
when true 'E:\WHC_Reject.log'
else 'E:\Load_Report.txt' end,

@subject = 'Daily data load'

any help is highly appreciated!!

thanks





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.