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
Note: To use this action, you have to set up the Email settings. Press button on the toolbar or write the code manually.
'********** Send email with old data record (VB) ************
Dim email = "[email protected]"
Dim from = "[email protected]"
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 = "[email protected]";
string from = "[email protected]";
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:
•Send an email to selected users
•How to email selected records as separate PDF files