Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SMTPClient question


SMTPClient question

Author
Message
terry_stjean
terry_stjean
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 77
I have a package using the Send Email Task.
On the SMTP connection, I have the smtp server specified and the Use Windows Authentication checked and the Enable Secure Sockets Layer unchecked.
Now, I want to send an email that has some data from a table embedded in the body.
So, I have added a Script Task with the following code:
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient

myHtmlMessage = New MailMessage("FromEmailaddress", "ToEmailAddress", "Test", Msg)
mySmtpClient = New SmtpClient("smtp.server")
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
myHtmlMessage.IsBodyHtml = True

Try
mySmtpClient.Send(myHtmlMessage)
Catch ex As Exception
MsgBox(ex.Message.ToString)
Dts.TaskResult = Dts.Results.Failure
End Try

The FromEmail and ToEmail are my own network email and the SMTPClient is my companies SMTP server, which is the same entry I had in the SMTP Connection Manager for the Send Email Task.
When I run the code, I don't get any errors but I never receive the email.
I'm trying to figure out why the Send Email Task works but this code does not.
Any help would be great.



anthony.green
anthony.green
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6102 Visits: 6078
What type of mail server do you use for SMTP? If its Exchange and you use the mail relay functionaity you need to ensure that you allow the IP address of the server where the mail is being sent from is allow to connect and send via the mail relay admin GUI, there are two places you need to add the IP.
Then also check that you dont have some sort of antivirus issue going on where it blocks mass mail worms, just to be on the safe side as I know from past experiences we had issues with McAfee stopping the mail services of SQL from sending and needed to be over-ridden by en ePO policy change.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


terry_stjean
terry_stjean
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 77
The server is Exchange. Anti-virus is not an issue.
As far as IP addresses go, wouldn't I have the same issue running the Send Email task (which works) on the same server??



anthony.green
anthony.green
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6102 Visits: 6078
Doh, yeah I missed that part when reading your post, my bad, sorry on that.

Could you not make use of using DBMail instead if your passing over the results of a query via an execute SQL task instead of creating a script task to do it?



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search