{{tag>Index Email Outgoing Process Intelligent_Business_Object}}
[<10>]
====== Sending Outgoing E-mail ======
Many applications need to send e-mails – to their customers, internal staff etc. As described in the [[docs:2500_config_apps:0500_add_edit_objects:0600_intelligent_bo|Defining Intelligent Business Objects]] section to send e-mails you need to define the party you are sending e-mails to as an intelligent business object and define the e-mail communication channel for this object – see [[docs:2500_config_apps:0500_add_edit_objects:0600_intelligent_bo:00050_setting_up_email|Setting Properties of E-mail Channel]].
The settings for sending emails can be defined if you double click on the business space version and select the "Outgoing Emails" property. The following properties should be specified:
===== Outgoing mail host =====
The DNS name of your e-mail server that will send outgoing e-mails to the intelligent business object.
===== "From" address =====
The e-mail address that your e-mails to the business object will have as the “from” address. Note that the "from address" must be recognized by your email server, so it must be registered on this server.
===== Login details =====
If your outgoing e-mail server requires that you log in select the “Login Required” option, press the Details button and enter login credentials. Otherwise select the “No Login Required” option.
====== OAuth Support ======
Some email providers require OAuth authentication, in which case you have to provide the details by ticking the "OAuth support" checkbox and providing OAuth settings. This is very much like providing OAuth settings for REST communication see [[docs:2500_config_apps/0500_add_edit_objects/0600_intelligent_bo/0400_setting_rest_channel_props]]
====== E-mail Notification ======
The actual e-mail sent to the external party represented by the intelligent business object must be a notification – see [[docs:2500_config_apps:1200_add_edit_notifications|Adding/Editing Notifications]]. It is up to you how you define the attributes of this notification and the rules that will be executed when this notification is created. However, you have to make sure that you define the following attributes in the notification representing an outgoing e-mail:
- ''Subject'' – this attribute must be of the Plain Text type and must contain the subject of the e-mail.
- ''Message'' – this attribute must be of the Plain Text type and must contain the body of the e-mail.
- ''HTMLMessage'' – this attribute must be of the Document type. If value of this attribute is defined and contains valid HTML document, the email will be sent in HTML format rather than in a standard text format.
- ''CC'' and ''BCC'' - these attributes represent copy and blind copy lists respectively. The email addresses in the list must be separated by a semi-colon. You can initialize the list from a list of references by using the ''[[a_f:f:af:list_line|LIST_LINE]]'' function.
You can also optionally add the EHeaders attribute to this notification if you want to add special headers to your email. The value of this attribute should be in the following format:
Header1#Header2#Header3...
where each header represents name and value in the standard header format:
Name: value
The Configuration Tool provides a convenience feature that creates the skeleton of the outgoing e-mail notification with all the required attributes automatically. You can use this feature to add the notification and then change it as you wish. To create the outgoing e-mail notification:
- Right click on the "Notifications" node of the business space version in the Elements Tree to bring up the pop-up menu.
- Select the "Add Outgoing E-mail Notification" command from the pop-up menu. The new notification with the name OutgoingEmail will appear in the Elements Tree.
Using the steps described above you can add as many outgoing e-mail notifications as you like. You can then change their names, add other attributes and/or attach creation rules – see [[docs:2500_config_apps:0800_add_edit_rules|Adding/Editing Rules]].
An email account that will be used when sending a notification is determined either from the SEND action itself or from the properties of the Email channel defined for the intelligent object if the account is not specified in the ''[[a_f:a:send|SEND]]'' action. An email account contains properties such as email server, port and authentication details.
If you want to use an email account directly in the ''[[a_f:a:send|SEND]]'' action you need to do the following:
- Create the definition of the email account object in the Configuration Tool by selecting the Business Objects node in the tree and then choosing "Add Outgoing Email Account" menu command. This command will create the object with the required predefined attributes
- Define the ''[[a_f:a:send|SEND]]'' action with the ''USING'' syntax. The instance of the ''EmailAccount'' object is taken from the Context of the rule – exactly one instance of this object must be present in the Context
- At runtime the user needs to populate the values of the ''EmailAccount'' object before invoking a process that uses the account in the ''SEND'' action.