Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Predefined actions

Events. Send email with old data

Scroll Prev Next More

 

Send email with old data record action allows, upon changing the record, emailing the previous data.

 

You can edit several parameters: the text and the subject of the message, the sender and recipient email addresses.

 

Available in the following events:

Edit page: Before record updated

Edit page: After record updated

List page: Before record deleted

send_email_with_old_data_select_action

 

Note: To use this action, you have to set up the Email settings. Press button email_settings_button_events  on the toolbar or write the code manually.

 

 

 

'**********  Send email with old data record (VB) ************
Dim email = "test@test.com"
Dim from = "admin@test.com"
Dim msg = new StringBuilder("")
Dim subject = "Sample subject"
 
' modify the following SQL query to select fields you like to send
Dim rs = CommonFunctions.db_query("select * from " & GlobalVars.strTableName.ToString() & " where " & where.ToString(), Nothing)
 
Dim data = CommonFunctions.db_fetch_array(rs)
 
If CType(data, Boolean) Then
  For Each field In data.GetEnumerator()
     msg.Append(field.Key.ToString() & " : " & field.Value.ToString() & Environment.NewLine)
  Next
  Dim ret = MVCFunctions.runner_mail(new XVar("to", email, "subject", subject, "body", msg.ToString(), "from", from))
  If Not CType(ret("mailed"), Boolean) Then
     MVCFunctions.Echo(ret("message"))
  End If
End If

 

//**********  Send email with old data record (C#) ************
string email = "test@test.com";
string from = "admin@test.com";
StringBuilder msg = new StringBuilder("");
string subject = "Sample subject";
 
// modify the following SQL query to select fields you like to send
XVar rs = CommonFunctions.db_query("select * from " + GlobalVars.strTableName.ToString() + " where " + where.ToString(), null);
 
XVar data = CommonFunctions.db_fetch_array(rs);
if(data)
{
  foreach(var field in data.GetEnumerator())
  {
    msg.Append(field.Key.ToString() + " : " + field.Value.ToString() + "\r\n");
  }
  XVar ret = MVCFunctions.runner_mail(new XVar("to", email, "subject", subject, "body", msg.ToString(), "from", from));
  if(!ret["mailed"])
  {
    MVCFunctions.Echo(ret["message"]);
  }
}

See also:

runner_mail function

Send mass email to all users

Send an email to selected users

Send email with new data

Send simple email

Email selected records

How to email selected records as separate PDF files