Difference between revisions of "HowTo:Send Messages to Multiple Recipients"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 52: Line 52:
:'''Advantage:''' Ultimate flexibility.
:'''Advantage:''' Ultimate flexibility.
:'''Disadvantage:''' Requires a small amount of code and the "wiring" to invoke it.
:'''Disadvantage:''' Requires a small amount of code and the "wiring" to invoke it.
:''Learn more:'' [[Java Code Samples#Send an Email Message]]


===Wrap Up===
===Wrap Up===

Revision as of 03:05, 29 January 2014

For:   Designers
Level: Beginner
Time:  10 minutes

See more:
    ◾ HowTo Guides

There are many ways to send a single message to multiple recipients. This writeup summarizes the possibilities, so you can choose the mechanism that is most appropriate for your application.

User-Controlled

When sending an email from a Case or from any other record in the system, a user can add as many recipients as they like.
Advantage: Infinite flexibility
Disadvantage: Requires manual effort that becomes excessive when duplicated my different users and/or repeated by the same user.
Learn more: Respond to a Case or Add a Note

Template-Controlled Addresses

When creating an Email Template, a comma-separated list of recipients can be specified.
Rules and Processes can then be used to send a message using that template. (Or for records other than Case records, the template to use can be selected by the user.)
There are multiple ways to do it:
  • Individual recipient addresses can be hard-coded into the To, Cc, or Bcc fields.
  • Template Variables can reference Lookup fields in the record to include email addresses from related Contacts and Users.
Advantage: Addresses can be taken from related Contacts and User records
Disadvantage: Each value is a single address, which is fine unless you need to send to a list or recipients.

List of Addresses in a Record

An Email Address field can be added to the object. For a given record, that field can contain a single email address or a comma-separated list of addresses. That email field can then used as a template variable in one of the template lists.
Advantage: Every record can have it's own unique set of addresses
Disadvantage: Address values have to be added to every record.

List of Addresses in a Related Record

Sometimes, an object already contains a Lookup to an object that could be augmented with an email list. For example, if each incoming Case were assigned to an specific Department using a record that gave the name and telephone number of the department manager, then an Email Address field could be added to the Department object, and that value could be used as a variable in the Email Template.
Advantage: Every record is automatically associated with the appropriate list.
Disadvantage: Requires a related object that will always be targeted by a Lookup, when records are processed.

Using an External "Alias"

One or more of the addresses contained in an email field could also be an email alias--a list of email addresses maintained on a separate server.
Advantage: Ability to re-use a list that is already being maintained elsewhere.
Disadvantage: If the email alias is maintained on an LDAP server, for example, this technique will work only for an On-Premise Installation of the platform--because the LDAP server is typically deployed behind a firewall, for protection.

Store Addresses in a Configuration Object

As an example, you could create an object called 'Notifications that has two fields:

  • Category - a name you use to designate the kind of notification you are doing.
  • Recipients - An Email Address field that contains a single email address or a comma-separated list of addresses. (Or even email aliases, for an On-premise Installation.)

You can then use Rules and Processes to send an Email, specifying a template that uses the recipient-list specified by a given record.

Advantage: Highly flexible. You can change a recipient list by editing a record, rather than modifying a template. The list can be used in multiple templates.
Disadvantage: Requires setting up a configuration object.

Retrieve Addresses Programmatically

Using any of the internal storage mechanisms for a list of email address, you can programmatically access that list and use the Java sendMail API to send a message to that list.

__TBD: using a template__

After writing a class like the following, the method it contains could then be invoked from a Rule or a Process.

<syntaxhighlight lang="java" enclose="div">

</syntaxhighlight>

Advantage: Ultimate flexibility.
Disadvantage: Requires a small amount of code and the "wiring" to invoke it.
Learn more: Java Code Samples#Send an Email Message

Wrap Up

At this point, you've seen a number of ways to send a message to a list of users, along with the advantages and disadvantages of each approach. You should now be able to pick the approach that will work best for your application.