开发者

Windows Task Scheduler running application but cannot send email

In my windows task scheduler, I have scheduled a task to run a c# console application executable on a daily basis. This application sends some data to the database and then sends an email.

When I run it normally it works but however when it is run through task scheduler, it sends data to the database but is unable to send the email.

Any ideas on how to fix this?

EDIT:

Yes I can send correctly through console application. It uses default network credentials..However when I look at the event logs I have the following .NET Runtime exception logged:

Framework Version: v4.0.30319

Description: The process was terminated due to an unhandled exception.

Exception Info: System.IO.IOException

Stack:

at iTextSharp.text.pdf.PdfPages.WritePageTree()

at iTextSharp.text.pdf.PdfWriter.Close()

at iTextSharp.text.pdf.PdfDocument.Close()

at iTextSharp.text.Document.Close()

at ReadReutersRates.Program.SavePDF(System.DateTime)

at Re开发者_StackOverflow中文版adReutersRates.Program.Main(System.String[])

I think it has something to do with pdf file which I am attaching to the email. But it's quite strange that this works when I manually run it.


This is a permissions error, the user you're running the task as when running through the console will have more permissions than the user running the task.

It appears the PDF app you are using is trying to write to a temp file or similar and it doesn't have permissions. (I'm assuming the email has a PDF attachment or similar that is being generated on the fly)

If you made your task run as an administrator that should work, you could then run it as a more restricted user and work out which permissions to apply to where to lock it down.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜