SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sending email using Send Email Task


Sending email using Send Email Task

Author
Message
forum member
forum member
SSC-Enthusiastic
SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)SSC-Enthusiastic (166 reputation)

Group: General Forum Members
Points: 166 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
Erik Kutzler
Erik  Kutzler
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1247 Visits: 1697
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.
Scott Coleman
Scott Coleman
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7124 Visits: 1531
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.



Mark Starr
Mark Starr
Mr or Mrs. 500
Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)Mr or Mrs. 500 (503 reputation)

Group: General Forum Members
Points: 503 Visits: 2571
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.
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