question

priyank avatar image
priyank asked

sql server jobs

I am executing csharp code thruogh a job using xp_cmdshell command to execute the code. If I am executing the code directly then i am able to send an email when an exception occurs. But if i am running the same code through job i am unable to send email. The exception gets logged to the database all the time. How can i send email through my code when i am executing that code through sql server jobs to send the email. can anyone help me on this. thanks.
sql-server-2008
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Wimbush avatar image David Wimbush commented ·
What happens when you try to send email? Is there an error?
0 Likes 0 ·
ramesh 1 avatar image
ramesh 1 answered
use database email to send mail , as jobs are maintened and execute by agent serveices, it does not send email, go to agent services--->properties--> enable dataabase mail
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image
ThomasRushton answered
It sounds as though the account under which SQLAgent runs isn't allowed to send email. Are other jobs sending email successfully? What are you using to do the email?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.