Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sending email using Send Email Task Expand / Collapse
Author
Message
Posted Sunday, September 13, 2009 10:59 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 1, 2011 10:58 AM
Points: 76, Visits: 906
Hi,

How can i customize the send email task to send email only once a day instead of every time job runs

Thanks for help

Post #787180
Posted Monday, September 14, 2009 8:46 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, August 31, 2012 10:31 AM
Points: 633, Visits: 1,695
You can't customize the Send Mail Task to do that, but there are a number of different approaches you can take to do this.

1) Replace the Send Mail Task in your package with a SQL task that stores any information that would have been in the email into a table with a datetime stamp. Create a second package scheduled to run once a day that retrieves the information from the table for the current date and places it in the body of the email.

2) Keep the Send Mail Task in the package. Create a package variable that will store a date and a way to update/retrieve this value (package configuration, Execute SQL Task, etc.) Add a Script Task or a precedence constraint on the task that compares this date value to the current date, and if different, execute the Send Mail Task. Instead of using a date, you could use a flag, etc.
Post #787519
Posted Tuesday, September 15, 2009 12:27 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, September 11, 2014 8:07 AM
Points: 2,844, Visits: 1,154
You could use an expression that evaluates the time of day and determines whether this is the correct time to execute the Send Email task. This expression could be used to set the Disable property of the task, or could be used as a constraint on the control-flow precedence arrow leading to the task, or on the Disable property of a Sequence Container containing the task, and so on.

For debugging purposes, it would be best to use the expression to define a boolean variable, then refer to the variable in whatever property expression you decide to use. Then you can set a breakpoint and check the value of the variable before it gets to the task. Keep in mind that the Variables pane does not update the variable values at run time, you must use the Add Watch or Quick Watch panes to see them.



Post #788449
Posted Tuesday, October 13, 2009 11:06 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 1:53 PM
Points: 122, Visits: 2,444
forum member (9/13/2009)
Hi,

How can i customize the send email task to send email only once a day instead of every time job runs

Thanks for help



Hello Forum Member,

Please excuse the lateness of this resonse - I'm just geting through my backlog...

Look into possiblly activating / deactivating the service broker queue:
ALTER QUEUE [ExternalMailQueue] WITH ACTIVATION (
STATUS = ON,
PROCEDURE_NAME = [dbo].[sp_sysmail_activate],
MAX_QUEUE_READERS = 1,
EXECUTE AS OWNER)

And reference (the following is not documented in my BOL, but the SP is there):
EXEC msdb.[dbo].[sp_sysmail_activate]

You could, perhaps run a daily job to activate the broker, then deactivate it a few minutes later?
Hope you find a way to accomplish your goals,


Mark
Just a cog in the wheel.
Post #802288
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse