Chilkat Email Components Home

NTLM Authentication in SQL Server Agent or AT Batch

Back

Question:
I have written a VB.NET console application that generates a PDF report and then sends it out to an email address.

Here’s the strange thing: When I run the program from the command line, it works perfectly. But when I schedule it in either the AT batch command or in SQL Server Agent, it returns the following error:

SMTP_Connect:
      Connecting to SMTP server 123.123.111.111:465
      smtp_host: 123.123.111.111
      smtp_port: 465
      smtp_user: my_username
      InitialResponse: 220 exch.mail.mycompany.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at  Wed, 20 Sep 2006 12:14:42 -0400 
      login_method: NTLM
      Finished and NOT authenticated
    ChilkatSSPI.authenticate: failed to prepare next package
    NTLM authentication failed
    Failed to login using NTLM method
  Failed to connect to SMTP server.
I’ve tested over and over: command line: works. AT or SQL Agent: Error. Can’t be permissions. I’m logged in as administrator.

Any idea of where to look?

Answer:
I think the NTLM authentication method is sensitive to the running process's logged-on user. No worry because you don't need to use it anyway. Because you're communicating via SSL (port 465), the complete SMTP session is encrypted, including the authentication, so you can instead force the Chilkat component to use the "LOGIN" auth method. Simply set the mailman.SmtpAuthMethod = "LOGIN". (Not your login name, but the literal string "LOGIN")

There is no source code associated with this article.