Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_sendmail and attachments

Status
Not open for further replies.

PRMiller

Technical User
Mar 18, 2004
95
US
Having trouble sending an attachment from the query analyzer using xp_sendmail. Here's my code:

Code:
EXEC master..xp_sendmail @recipients = 'me@mymail.com', 
  @subject = 'Snapshot',
  @attachments = 'c:\Off-Line\Snapshot\rpt_Snapshot.snp'

I receive the error "xp_sendmail: failed with mail error 0x80004005". Removing the attachments line allows the code to run fine and send me an e-mail, so I know my permissions have not changed.

Thinking I misspelled the file directory, I moved the file to the root directory on the C drive, but still had no luck.

Any suggestions?
 
when you run this in QA this path (c:\Off-Line\Snapshot\rpt_Snapshot.snp) that xp_sendmail is looking for is on the SQL server not on your local machine

try running this master..xp_cmdshell 'dir c:'and look for the file there




“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Woops, that would explain it. Well, the file is on my local machine. Is there any way to use sendmail to attach a file from my PC?

Otherwise, I'm thinking I could load it to a server, something like @attachments = '\\Servername\Director\File.snp'
 
Only if the server can see your machine and create a share and map it
easier and more secure would be to store it on the SQL server

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
True. In this case, security isn't an issue as the file will be mailed out to a distribution.

I changed the output destination to the network, and now sendmail picks it up.

Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top