0
votes

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?

1
Are there any errors in the SSIS log, or the event log of the SQL server? If possible I would write a small .net console app to try sending a mail from the SQL server to see if you get an error from that. Last time I had problems like this the SMTP server was configured to only allow mail from certain clients.Lobsterpants
Talk to your Exchange administrator. Ask whether they see anything in the logs on their end. As Lobsterpants indicates, there may be Exchange level rules prevent the delivery of email.billinkc

1 Answers

1
votes

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.