SMTP サーバー、受信者リスト、件名、本文、および複数の添付ファイルのすべてが実行時に決定される E メールを作成できます。
複数の添付ファイルのある E メールを作成するメッセージ・フローを作成できます。 1 つの添付ファイル、静的な件名、および静的な本文のある E メールを静的な受信者リストに送信するように EmailOutput ノードを構成するには、添付ファイル付きの E メールの送信を参照してください。
E メールの送信時に設定したノード・プロパティーは任意指定にでき、ローカル環境で指定した値、E メールの出力ヘッダー (EmailOutputHeader)、またはメッセージの本文によって実行時に指定変更できます。 この方式を使用するには、メッセージ・フロー内の前のノードでこれらの指定変更を構成しなければなりません。 E メールの本文のノード・プロパティーでテキストの値が指定されていない場合は、EmailOutput ノードに渡されたメッセージが使用されます。
以下の例では、ESQL (Compute ノードを使用) および Java™ (JavaCompute ノードを使用) で受信者、送信者、件名、SMTP サーバー、およびメッセージ本文の情報をセットアップする方法を示します。
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
-- Add recipient information to the EmailOutputHeader
SET OutputRoot.EmailOutputHeader.To = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Cc = '<recipient email address>';
SET OutputRoot.EmailOutputHeader.Bcc = '<recipient email address>';
-- Add sender information to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.From = '<sender email address>';
SET OutputRoot.EmailOutputHeader."Reply-To" = '<reply email address>';
-- Add subject to EmailOutputHeader
SET OutputRoot.EmailOutputHeader.Subject = 'Replaced by ESQL compute node.';
-- Add SMTP server information to the LocalEnvironment
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- Create a new message body, which will be sent as the main text of the email.
SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);
RETURN TRUE;
END;
DECLARE crlf CHAR CAST(X’0D0A’ AS CHAR CCSID 1208);
DECLARE myEmailBodyTxt CHAR;
SET myEmailBodyTxt [equals char] 'this is the first line' || crlf ||
:NONE.'this is the second line' || crlf ||
:NONE.'this is the third line';
SET OutputRoot.BLOB.BLOB = CAST(myEmailBodyTxt AS BLOB CCSID 1208);
public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
// Create a new assembly to propagate out of this node, as we want to update it
MbMessage outMessage = new MbMessage();
copyMessageHeaders(assembly.getMessage(), outMessage);
MbMessage outLocalEnv = new MbMessage(assembly.getLocalEnvironment());
MbMessage outExceptionList = new MbMessage(assembly.getExceptionList());
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly, outLocalEnv, outExceptionList, outMessage);
MbElement localEnv = outAssembly.getLocalEnvironment().getRootElement();
// Create the EmailOutputHeader parser. This is where we add recipient, sender and subject information.
MbElement root = outMessage.getRootElement();
MbElement SMTPOutput = root.createElementAsLastChild("EmailOutputHeader");
// Add recipient information to EmailOutputHeader
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "To", "<recipient email address");
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Cc", "<recipient email address");
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Bcc", "<recipient email address");
// Add sender information to EmailOutputHeader
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "From", "<sender email address>");
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Reply-To", "<reply email address>");
// Add subject information to EmailOutputHeader
SMTPOutput.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Subject", "Replaced by Java compute node.");
// Create Destination.Email. This is where we add SMTP server information
MbElement Destination = localEnv.createElementAsLastChild(MbElement.TYPE_NAME, "Destination", null);
MbElement destinationEmail = Destination.createElementAsLastChild(MbElement.TYPE_NAME, "Email", null);
destinationEmail.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "SMTPServer", "<smtp.server:port>");
// Set last child of root (message body)
MbElement BLOB = root.createElementAsLastChild(MbBLOB.PARSER_NAME);
String text = "This is the new text for the body of the email";
BLOB.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", text.getBytes());
outMessage.finalizeMessage(MbMessage.FINALIZE_VALIDATE);
out.propagate(outAssembly); }
ローカル環境 | 説明 |
---|---|
Destination.Email.SMTPServer | SMTP サーバーの「サーバー : ポート」。 ポートはオプションです。 指定しなかった場合、デフォルト値は 25 になります。 |
Destination.Email.SecurityIdentity | SMTP サーバーでの認証のためのセキュリティー ID。これは、mqsisetdbparms コマンドを使って定義されたユーザー ID とパスワードのペアの名前にすることができますが、mqsisetdbparms コマンドを使って定義されたユーザー ID とパスワードを参照する securityIdentity 属性を持つ外部リソースを参照してもかまいません。 どちらの場合も、値はストリング“smtp::”の後に付加されます。 例えば、mqsisetdbparms コマンドを使用して smtp::myUseridPassword というユーザー ID とパスワードを作成する場合、ノード上で指定するかまたは外部リソース内に間接的に指定する securityIdentity は、myUseridPassword になります。 |
Destination.Email.BodyContentType | E メール・メッセージの本体に含まれているのがプレーン・テキストではなく、HTML であることを識別します。 このプロパティーは text/plain、text/html、 または text/xml に設定します。text/plain がデフォルト値です。 |
Destination.Email.MultiPartContentType | 関連、混合、代替など、複数パーツのタイプ。 ここでは任意の値を設定できます。 |
Destination.Email.Attachment.Content | 実際の添付ファイル (BLOB/text)、またはエレメント (例えば、メッセージ・ツリーまたは LocalEnvironment 内のエレメント) を参照する XPath 式か ESQL 式。 参照エレメントの値は添付ファイルの値として取得されます。
|
Destination.Email.Attachment.ContentType | text/plain、text/html、および text/xml など、添付ファイルのタイプ。 (インターネット・メディア・タイプとも呼ばれる)。 ここでは任意の値を設定できます。 |
Destination.Email.Attachment.ContentName | 添付ファイルの名前。 |
Destination.Email.Attachment.ContentEncoding | 添付ファイルのエンコード。7bit、base64、または quoted-printable。
|
場所 | 説明 |
---|---|
Root.EmailOutputHeader.To | E メール・アドレスのコンマ区切りリスト。 |
Root.EmailOutputHeader.Cc | E メール・アドレスのコンマ区切りリスト。 |
Root.EmailOutputHeader.Bcc | E メール・アドレスのコンマ区切りリスト。 |
Root.EmailOutputHeader.From | E メール・アドレスのコンマ区切りリスト。 |
Root.EmailOutputHeader.Reply-To | E メール・アドレスのコンマ区切りリスト。 |
Root.EmailOutputHeader.Subject | E メールの件名。 |