Reputation: 29
I am trying to send mail in SQL Server. I have a SSIS package the sends the mail using a script task.
When I run that package in Visual Studio, the mail sends. When I let SQL Server run the package, the package "succeeds" but no mail sends. When I set it up with a Send Mail Task & SMTP Connection Manager, the mail sends in SQL Server.
I would think that because the using an SMTP connection manager allowed the mail to send, that mimicking those credentials in the code would also make the email send. The connection manager had the settings: SMTP Server: MAIL.XXXXX.COM Use Windows Authentication: no Enable SSL: no
When I create the SMTP client in the script, I use
mySmtpClient = new SmtpClient("MAIL.XXXXX.COM");
mySmtpClient.EnableSsl = false;
mySmtpClient.Send(htmlMessage);
Why doesn't the email send through code, if it does when using a connection manager?
Upvotes: 0
Views: 239
Reputation: 29
I found the solution -- in the job properties of the send mail job on SQL Server job, I had to go to the Job Step Properties, click on the tab called data sources, and check the box to use the SMTP Connection Manager from the package.
Upvotes: 1