mdProgrammer
Programmer
I created a simple test application that automatically sends an email (it's eventual use will be sending secure email based on what's in a table - yes, I know about SQL Server 2008's email capabilities, but it's not set up, and I'm not the one that sets the servers up). This application works on my local computer.
For reference, this is the code (there's no input needed) -
Now, I created a SQL Job on my SQL Server database whose only step is to run this application. The setup is:
Type: Operating System (CmdExec)
Run As: SQL Server Agent Service Account
Command: E:\Projects\test\EmailTest\EmailTest\bin\Release\EmailTest.exe
The owner is myself.
When I run the job, it hangs at "Execute Job 'TestEmail'". I've read some things about security permissions, and I even tried giving "everyone" full control (I know that's a security hazard, but that's just for testing), and it still didn't work. Anyone have any suggestions?
For reference, this is the code (there's no input needed) -
Code:
Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class Form1
Private Account As Outlook.Account
Private olApp As Outlook.Application
Private olSession As Outlook.NameSpace
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim olAccounts As Outlook.Accounts
olApp = New Outlook.Application()
olSession = olApp.Session
olAccounts = olSession.Accounts
Account = olSession.Accounts(1)
' Create the Email
Dim item As Outlook.MailItem
Me.Hide()
item = olApp.CreateItem(Outlook.OlItemType.olMailItem)
item.Subject = "Test Subject" 'TextBox2.Text
item.Body = "Test Message" 'RichTextBox1.Text
item.Recipients.Add("jgasiorowski@dors.state.md.us") 'TextBox1.Text)
item.Recipients.ResolveAll()
item.Send()
Close()
End Sub
Now, I created a SQL Job on my SQL Server database whose only step is to run this application. The setup is:
Type: Operating System (CmdExec)
Run As: SQL Server Agent Service Account
Command: E:\Projects\test\EmailTest\EmailTest\bin\Release\EmailTest.exe
The owner is myself.
When I run the job, it hangs at "Execute Job 'TestEmail'". I've read some things about security permissions, and I even tried giving "everyone" full control (I know that's a security hazard, but that's just for testing), and it still didn't work. Anyone have any suggestions?