I’ve got a console app that get some data from a db, put them into an existent excel, then send the filled excel via email. The app works fine if I manually launch it from prompt, but if I schedule a task that launch the app, the app start, I can see excel in task manager, but all seems to be hang and the app doesn’t send email.
This is the code part using excel automation.
Var excel As New ExcelApplication
excel.Workbooks.Open(templateXls.NativePath)
var row as Integer = 2
var cell as String
While not r.AfterLastRow
For c as Integer = 0 to r.ColumnCount-1
cell = chr(65+c)+row.ToText
if r.ColumnAt(c).Name = "LDAINF" or r.ColumnAt(c).Name = "LDFATT" or r.ColumnAt(c).Name = "LDAFIF" then
excel.Range(cell).Value = dateAs2ggmmyyyyy(r.ColumnAt(c).Int64Value)
else
excel.Range(cell).Value = r.ColumnAt(c).StringValue
end If
next
row = row + 1
r.MoveToNextRow
wend
excel.ActiveWorkbook.SaveAs(output.NativePath)
Excel.Quit
Excel = Nil
Any ideas?