Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp_send_dbmail to send multiple attachement

Author  Topic 

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2010-04-14 : 16:04:10
Im unable to send multiple attachment using sp_send_dbmail.

SET NOCOUNT ON
EXEC msdb.dbo.sp_send_dbmail
@recipients='xxxx.xxxx@xxxx.org,
@subject = @sub,
@body = @tableHTML,
@body_format = 'HTML',
@profile_name = 'Refresh',
@file_attachments =@2PATH;@1PATH;

I only get the attachment of @2PATH file in my email.

I have tried as suggested to include 'SET NOCOUNT ON'.No luck
If I were to try one variable at a time.It works fine

How do I do this ?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-14 : 16:06:52
You have to build @file_attachments.

DECLARE @s varchar(500)

SET @s = @2PATH + ';' + @1PATH

Then pass @s to @file_attachments

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2010-04-14 : 16:36:05
Tara,

I still get only the first attachment
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-14 : 17:07:45
Do a PRINT command to ensure you have properly formed the variable.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2010-04-15 : 14:59:21
Hi Tara,

Print comes up with
'\\xx.xx.xx.xx/d$/DailyErrorLog/DailyErrorLog.txt;\\xx.xx.xx.xx/d$/DailyErrorLog/DailyErrorLog.txt'
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-15 : 19:13:45
Your slashes are going the wrong way. They all should be \ and not /. Also your files appear to be the same, so make sure you are sending unique files. See if that helps and let me know. I return to work on Monday (been on maternity leave), so I can help you then if you are still having problems.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2010-04-16 : 09:06:30
Hi Tara,

Yes both file names were the same.I changed it and the slashes as well.Got it to work.Thank You so much.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-16 : 13:23:35
You're welcome!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -