axConnectorEmail

Description

axConnectorEmail provides the ability to send an email using the ConnectorJS service email.

Usability

Context

Supported

Input screen fields

Yes

Output screen fields

No

Input subfile fields

No

Output subfile fields

No

Properties

Name

Description and Comments

JavaScript

Shipped default

asynchronous

Send with asynchronous call or not.

Yes. Must return a Boolean.

True.

emailRequest

Server’s email object identifier.

Yes. Must return a string.

ANY.

from

The sender's email address to set.

Yes. Must return a string.

None.

hostEndPoint

Web service endpoint URL.

Yes. Must return a string.

None

hostPassword

Password.

Yes. Must return a string.

None.

hostUserId

User id.  

Yes. Must return a string.

None.

onEmailSendCompleted

JavaScript code to be executed when the email is sent with asynchronous call.

Yes.

// {Object} ENV.cmMessage{status, message}

smtpServer

The SMTP server to set.

Yes. Must return a string.

None.

Notes, Comments and Warnings

This eXtension works only in the advanced terminal emulator (TS2) and is not intended to be run in the basic terminal emulator (TS1).

This eXtension is composed of different eXtensions such as:

Image

All the extensions inside this eXtension has the following behaviour:

Can only be dragged within the boundaries of axConnectorEmail eXtension

Cannot be deleted.

When double-clicked, the selection is moved to axConnectorEmail eXtension. Thus, allowing the add eXtension only to axConnectorEmail extension itself.

When right-clicked, the selection is moved to axConnectorEmail eXtension.

Thus, allowing the context menu to be available to axConnectorEmail extension only.

When this eXtension is resized, only the following fields are changed:

Width of To, Cc, Bcc and Subject input fields

Width and Height of the message field

When this eXtension is created, a value is automatically set to name property of this eXtension, all the input fields and message field. These names are used in the auto-generated code set on the onClick property of Clear and Send buttons. You can always change the predefined name any time, but be sure to update the code in the Clear and Send buttons and the name is not yet set to any existing eXtension.

Auto-generated code for Clear button is as follows:

FIELDS("cmto1").setValue("");

FIELDS("cmcc1").setValue("");

FIELDS("cmbcc1").setValue("");

FIELDS("cmsubject1").setValue("");

FIELDS("cmbody1").setValue("");

var CM = GETCMAILINSTANCE("cmail1");

CM.clearReceiversList();

Auto-generated code for Send button is as follows:

var CM = GETCMAILINSTANCE("cmail1");

CM.clearReceiversList();

var toFlds = FIELDS("cmto1").getValue().split(",");

var ccFlds = FIELDS("cmcc1").getValue().split(",");

var bccFlds = FIELDS("cmbcc1").getValue().split(",");

for (var i in toFlds)

CM.addReceiver(toFlds[i], AXES.IBMiService.ReceiverType.TO);

for (var i in ccFlds)

CM.addReceiver(ccFlds[i], AXES.IBMiService.ReceiverType.CC);

for (var i in bccFlds)

CM.addReceiver(bccFlds[i], AXES.IBMiService.ReceiverType.BCC);

CM.setSubject(FIELDS("cmsubject1").getValue());

CM.setBodyText(FIELDS("cmbody1").getValue());

CM.send();

This eXtension uses the connectorEmail widget that accesses the ConnectorEmail API. When this eXtension is rendered, an instance of AXES.IBMiService.ConnectorEmail API is created.

To get the instance to AXES.IBMiService.ConnectorEmail API used by this eXtension, use this code:

GETCMAILINSTANCE( <base name> );

      Where <base name> is the value of the “name” property under the “Basic”

       sub-pane of the “eXtensions” pane in TS2 Developer.

GETCMAILINSTANCE is a common user function that retrieves the instance of AXES.IBMiService.ConnectorEmail API set in this extension.

asynchronous property

When set to true, the onEmailSendCompleted event acts as a callback function. The status of email sending and the message if there’s any can be accessed from ENV.cmMessage object.

When set to false, AXES.IBMiService.ConnectorEmail.send() returns the status. And the error message can be accessed by AXES.IBMiService.ConnectorEmail.getError().

Example

On the System i Main Menu, add the axConnectorEmail extension to the screen. Set a valid value to the following properties:

hostEndPoint: http://<endpointURL:port>/service/connector.jsp

hostUserId: <valid user id>

hostPassword: <valid password>

emailRequest: ANY

smtpServer: <valid server>

from: <valid sender email address>

asynchronous: true

onEmailSendCompleted: alert(ENV.cmMessage.status);

Save and unlock the screen.

Input valid email addresses for the To, Cc and Bcc input fields. You can specify multiple addresses by separating them with a semicolon.

Type an email subject in the subject input field, for example “axConnectorEmail test”

Type a message inside the message field, for example “This is a test email using ConnectorJS.”

Click the send button of the eXtension and then check that the message has been received in the email addresses you specified and the alert message will be displayed with its status.

See Also

Extension_ScriptingReference - aXes ConnectorEmail Object Functions and Features

Administrators

Legal Mentions

aXes is brought to you by:

LANSA

Serving the IBM i community for 30 years.