CodeCharge Studio
<!--- write your own code here --->
with the code below:
<CF_CCToSQL Value="#flduser_id_assign_to#" Type="#ccsInteger#"> <CF_CCDLookUp Field="email" Table="employees" Where="emp_id=#CCToSQL#" Connection="IntranetDB"> <CFSET mai1_To=CCDLookUp> <CF_CCToSQL Value="#Session.UserID#" Type="#ccsInteger#"> <CF_CCDLookUp Field="email" Table="employees" Where="emp_id=#CCToSQL#" Connection="IntranetDB"> <CFSET mai1_From=CCDLookUp> <CF_CCDLookUp Field="max(task_id)" Table="tasks" Where="user_id_assign_by=#CCToSQL#" Connection="IntranetDB"> <CFMAIL TO="#mai1_To#" FROM="#mai1_From#" SUBJECT="New task for you" TYPE="HTML" > The following task was submitted:<br><br> Task ID:#CCDLookUp# <br><br>#fldtask_desc# </CFMAIL>
The following is the explanation of the above code:
<CF_CCToSQL Value="#flduser_id_assign_to#"
Type="#ccsInteger#">
<CF_CCDLookUp Field="email" Table="employees"
Where="emp_id=#CCToSQL#" Connection="IntranetDB">
<CFSET mai1_To= CCDLookUp>
Sets the To email address to the email of the person that is assigned
to the task. The CCDLookUp custom tag is used here to retrieve the appropriate
email address.
<CF_CCToSQL Value="#Session.UserID#" Type="#ccsInteger#">
<CF_CCDLookUp Field= "email" Table= "employees" Where=
"emp_id=#CCToSQL#" Connection=quot;IntranetDB">
<CFSET mai1_From= CCDLookUp>
Sets the From email address to the value of the email field in
the employees table where emp_id matches the current user. The
CCDLookUp function is used to retrieve a database value, while Session.UserID
contains the id of the currently logged in user.
<CF_CCDLookUp Field="max(task_id)" Table="tasks"
Where="user_id_assign_by=#CCToSQL#" Connection= "IntranetDB">
Retrieves the current Task Id. The last inserted task id can be obtained using different methods with different databases. Unfortunately, MS Access doesn't support the retrieval of the last inserted record, therefore you will need to use the CCDLookUp function to retrieve the largest task id submitted by the current user (assuming that task ids are created incrementally).
<CFMAIL TO="#mai1_To#" FROM="#mai1_From#" SUBJECT="New task for you" TYPE="HTML" >
The following task was submitted:<br><br>
Task ID:#CCDLookUp#
<br><br>#fldtask_desc#
</CFMAIL>
The CFMail tag sends out an email address using the variables set within the tag. The body of the tag makes up the body of the email address that will be sent.
Next: Use the "After Update" Event to Send Emails