|
I need to create a vb script in order to Send an Email with Attachments. I am having no luck creating a simple script to email me in test with no attachments. In My Package i Have Variables Assigned for the following: In My Script Task I have ReadOnlyVariables for MailTo, MailFrom, SmtpServer ReadWriteVariable = MailSubject (I will try the message after I get it to just email successfully Here is my script Can Someone please help? This shows green as successful but no error messages ever appear and no messages appear.
(comments are locked)
|
|
There was a good example of this on MSSQLTips.com - http://www.mssqltips.com/tip.asp?tip=1753 You might try scarfing their example code to get you up and running quickly. You get a using statement for free by using their code (this addresses the memory leak issue raised by Oleg).
(comments are locked)
|
|
The code has some small problems. Here is what you can try to make it work: Add this line to the code to make sure that the message is sent in Html format Optionally set the priority: If you need to add any attachments to it then use this: And finally, please consider wrapping your message into the using block to prevent memory leaks. MailMessage type implements IDisposable interface, and so any instance of it should be disposed promptly after use. Oleg
(comments are locked)
|
|
Do you have to do this with VB? Can you not use Database Mail? What version of SQL Server are you running? SQL 2005 - The Send Mail Task is successful and would work perfectly but will not support html - I need to include a corporate logo
Feb 09 '11 at 10:00 AM
siera_gld
A quick search shows a lot of people who have been able to send the body of database mail with HTML. Try this link
Feb 09 '11 at 11:12 AM
Tim
MSDN lists the syntax for sending mail using db mail. Note the @body_format [ @body_format= ] 'body_format' Is the format of the message body. The parameter is of type varchar(20), with a default of NULL. When specified, the headers of the outgoing message are set to indicate that the message body has the specified format. The parameter may contain one of the following values:
Feb 09 '11 at 11:18 AM
Tim
TRAD - I think this is very close - the only trick for me is to pass in paramaters in - so this is going inside a foreach loop and every time it loops - i pass in a paramater for @file_attachments= ?; @recipients = ? and the subject and body have references to more package variables - so in the body of the email I use a contact name for the person and it varies on every numeration? I have tried sending myself an email from management studio and it appears like this might be successful but cant get it to work from within my foreach loop
Feb 09 '11 at 12:47 PM
siera_gld
(comments are locked)
|


I'm sure your suggestions will come in handy - The first hurdle I want to overcome is sending a mail successfully - at this moment I can't