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)
 Problem in running JOB - Sending Email

Author  Topic 

Pri
Starting Member

5 Posts

Posted - 2008-12-26 : 15:35:47
Hi,
I have created a job that has 2 steps
step 1 - create Excel file.
step - send excel file in email.

Both steps gets excuted sucessvily but sometimes I recieve emails and sometimes not. Please help me I am stuck .This is the code for sending emails.
EXEC msdb..sp_send_dbmail
@profile_name = 'SQLAdminProfile',
@recipients = @Usermail,
@subject = 'Sourcing Reveune Export File',
@file_attachments = '\\bosintranetdev\Reports\Excel\SourcingRevenueExport.xls',
@exclude_query_output = 1

if @@error = 0
Update SendSourceRevenue Set EmailStatus='Y', UpdatedOn=GetDate() where RequestedId = @ResquestId

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-26 : 18:48:21
What is the largest size that the file can be?

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

Subscribe to my blog
Go to Top of Page

Pri
Starting Member

5 Posts

Posted - 2008-12-26 : 22:20:04
Hi,
Maximum size of the file is 7MB. Sometimes I receive the file and sometimes not and If I run StoreProcedure on SQL Query Analyzer then I am able to receive 7 MB file in my email.Please help me I got stuck...Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-27 : 01:38:39
I'd contact the email server admin to see if the email made it out of the email server. Once Database Mail passes the email to the server, the job will show success even if it couldn't get any further.

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

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-27 : 01:39:47
Also, a 7MB file could get blocked by some email servers as some are configured to block attachments greater than 5MB. It's possible that you are hitting this on some occassions. Perhaps you could try compressing the file and then sending the zip instead.

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

Subscribe to my blog
Go to Top of Page

Pri
Starting Member

5 Posts

Posted - 2008-12-27 : 10:16:21
Thanks for your reply.
Database mail size limit is 100MB and job is running successfully but I am not receiving emails. Please suggest me how can I resolve this...Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-27 : 11:11:06
I guess you didn't read my last posts carefully. It's the email server that would block it, not Database Mail.

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

Subscribe to my blog
Go to Top of Page

Pri
Starting Member

5 Posts

Posted - 2008-12-27 : 23:49:44
Ok, but there is no email server and I am writing everthing is store procedure. How do I compress file in Store Proc?
What is Email Server and how can I prevent to block it..

Thanks fro your help.
Go to Top of Page
   

- Advertisement -