Flylib.com

Books Software

 
 
 

Generate Email Using Formula Language


Generate Email Using Formula Language

There are essentially two methods that can be used to generate an email using Formula Language @Command ([Mailsend]) and @MailSend . The @Command([Mailsend]) statement is used to send the current document to a list of recipients. @MailSend , on the other hand, is used to create and send a custom email message.

How It Works

The @Command([Mailsend]) command generates an email based on the current document. This statement is typically added to an action button on a form. This approach also requires the form to include a field called SendTo. This field must contain a valid list of one or more email addresses. Optionally, the form can also include Subject, CopyTo, and BlindCopyTo fields.

The @MailSend function sends a custom email message based on function call parameters instead of using field values on the document. With this approach, the email is generated by specifying the list of recipients, subject, and body information within the function. When executed, the function sends a message to all recipients listed in the SendTo, CopyTo, and BlindCopyTo fields. Like its counterpart , this function is also typically placed in an action button on the form. When clicked, the message is sent.

Tip

You may want to save and close the document after either button is pressed. This is achieved by appending @Command([FileSave]) to save the document and @Command([FileCloseWindow]) to close the document.


ImplementationExample 1

To implement the @Command([Mailsend]) approach, create a form that includes the SendTo and Subject fields. Next, create an action button and insert the following formula in the Programmer's pane. When clicked, the @Mailsend statement retrieves the field values from the document and sends the email message to the recipient list.

@Command ([MailSend])


ImplementationExample 2

To implement the @MailSend approach, create an action button and insert the following formula. Be sure to adjust the SendTo value to reflect all intended email recipients as well as the subject line.

SendTo := @UserName;
CopyTo := "";
BlindCopyTo := "";
Subject := "This is a sample email";
Remark := "";
BodyFields := "This is the body of the email.";
Flags := "";
@MailSend(sendTo ; copyTo ; blindCopyTo ; subject ; remark ; bodyFields ; Flags);
@Prompt([Ok]; "Success"; "Message sent.");




How to Sort a List of Values

Using the @Sort function, you can sort a list of values in descending or ascending order.

How It Works

The @Sort function is a built-in Formula Language function. This function requires two parametersa list of values and the sort order expression(s). There are numerous sort order expressions, including

Ascending [ASCENDING]

Descending [DESCENDING]

Accent-Sensitive [ACCENTSENSITIVE]

Accent-Insensitive [ACCENTINSENSITIVE]

Case-Sensitive [CASESENSITIVE]

Case-Insensitive [CASEINSENSITIVE]

Custom Sort [CUSTOMSORT]

Pitch-Sensitive [PITCHSENSITIVE]

Pitch-Insensitive [PITCHSENSITIVE]

One or more expressions can be specified in the function call. Each expression must be enclosed in brackets and separated by semicolons.

Implementation

To sort the list, simply include the list of values and sort order expression(s). The following illustrates how to sort a list of values in ascending order (see Figure 14.20). Simply replace the list of values or assign a field to the myValues variable. The @Prompt statement is used for illustrative purposes and can be removed or updated as desired.

myValues := "Mark" : "Ryan" : "Kyle" : "Alex";
result := @Sort ( myValues; [Ascending] );

@Prompt([Ok]; "Sample Sort";
"Original List: " + @Implode(myValues; ", ") + @NewLine +
"Sorted List: " + @Implode(result; ", "))


Figure 14.20. Example of the @Sort function