SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,592 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello, everyone.
I have a Visual Basic script within a SSIS Script Task to send mail inside the organization. We are usinng Microsoft Azure to manage the users accounts. Now, Microsfot is enforcing the MFA.
Now we're getting this error:
This is the script that has been executing for years:
#Region "Help: Introduction to the script task"
'The Script Task allows you to perform virtually any operation that can be accomplished in
'a .Net application within the context of an Integration Services control flow.
'Expand the other regions which have "Help" prefixes for examples of specific ways to use
'Integration Services features within this script task.
#End Region
#Region "Imports"
Imports System
Imports System.Data
Imports System.Math
Imports System.Net.Mail
Imports Microsoft.SqlServer.Dts.Runtime
#End Region
Public Sub Main()
'
' Add your code here
'
Dim varHTMLMail As MailMessage
Dim varSMTPClient As SmtpClient
Dim varDestinatarios As Object
Dim contenido As String
Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Ssl3 Or Net.SecurityProtocolType.Tls12 Or Net.SecurityProtocolType.Tls11 Or Net.SecurityProtocolType.Tls
varDestinatarios = "user1@test.com"
Try
varHTMLMail = New MailMessage()
varHTMLMail.From = New MailAddress("sender@test.com")
varHTMLMail.Subject = "Insert Text here"
contenido = "<head><style type=""text/css"" > h2, body {font-family: Arial, verdana;} table{font-size:11px; border-collapse:collapse;} td{background-color:#F1F1F1; border:1px solid black; padding:3px;} th{background-color:#99CCFF;}</style></head><body>"
contenido = contenido + Dts.Variables("Insert Text0").Value.ToString()
contenido = contenido + "<hr />"
contenido = contenido + Dts.Variables("Insert Text1").Value.ToString()
'contenido = contenido + "</body>"
contenido = contenido + "<hr />"
contenido = contenido + Dts.Variables("Insert Text2").Value.ToString()
'contenido = contenido + "</body>"
'MsgBox(contenido)
varHTMLMail.Body = contenido
varHTMLMail.To.Add("user1@test.com")
varHTMLMail.To.Add("user2@test.com")
varHTMLMail.To.Add("user3@test.com")
varHTMLMail.To.Add("user4@test.com")
varHTMLMail.To.Add("user5@test.com")
varHTMLMail.IsBodyHtml = True
Catch e As Exception
MsgBox(e.ToString())
End Try
Try
varSMTPClient = New SmtpClient("smtp.office365.com", 587)
varSMTPClient.Credentials = New Net.NetworkCredential("sender@test.com", "Mypass")
'varSMTPClient.UseDefaultCredentials = True
varSMTPClient.EnableSsl = True
varSMTPClient.Send(varHTMLMail)
Catch e As Exception
MsgBox(e.ToString)
End Try
Dts.TaskResult = ScriptResults.Success
End Sub
#Region "ScriptResults declaration"
'This enum provides a convenient shorthand within the scope of this class for setting the
'result of the script.
'This code was generated automatically.
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
#End Region
End Class
Looks like SMTP auth is disabled. See the following article to mitigate this: