Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 Integration Services
»
SMTPClient question
SMTPClient question
Rate Topic
Display Mode
Topic Options
Author
Message
terry_stjean
terry_stjean
Posted Wednesday, November 14, 2012 8:42 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, February 20, 2013 11:19 AM
Points: 11,
Visits: 72
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.
Post #1384683
anthony.green
anthony.green
Posted Wednesday, November 14, 2012 8:57 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
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
Post #1384695
terry_stjean
terry_stjean
Posted Wednesday, November 14, 2012 9:30 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, February 20, 2013 11:19 AM
Points: 11,
Visits: 72
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??
Post #1384729
anthony.green
anthony.green
Posted Thursday, November 15, 2012 2:11 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
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
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
Post #1385013
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.