July 24, 2009 at 9:09 am
I have decided to use the SCRIPT TASK feature in SSIS to send an HTML format email.
I found the code from this site....
Imports System
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net.Mail
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
myHtmlMessage = New MailMessage("###@hotmail.co.uk", "###@hotmail.co.uk","Subject line", "")
' myHtmlMessage.Attachments.Add(New Attachment("D:\file.txt"))
' Add a Content-Disposition header with the filename
' myHtmlMessage.Headers.Add("Content-Disposition", _
' "attachment; filename=""" & "file.txt" & """")
' myHtmlMessage.Attachments(0).ContentDisposition.DispositionType = "attachment"
' myHtmlMessage.Attachments(0).ContentDisposition.FileName = "FILE.txt"
mySmtpClient = New SmtpClient("172.25.10.58")
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(myHtmlMessage)
Dts.TaskResult = Dts.Results.Success
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
I have set the PrecompileScriptIntoBinaryCode to False, as it wasn't compiling before....
When I run it I get an error message, please see below
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ScriptTask_4c8e63b51114426a84b497b5bb6c942e.ScriptMain.Main() in dts://Scripts/ScriptTask_4c8e63b51114426a84b497b5bb6c942e/ScriptMain:line 24
What am i doing wrong?
July 28, 2009 at 2:21 am
any help guys
July 28, 2009 at 3:24 am
Hi Jo, I've tried your code with my email address, and our local exchange server and it worked fine. It seems that your peoblem is more with server config than your code. Is that IP address a hotmail server? I don't imagine you would be able to use CredentialCache.DefaultNetworkCredentials for logging into a hotmail account???
Cheers
Laurence
July 28, 2009 at 7:44 am
cheers, the problem is with my virus protection McaFee
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply