WebSphere Message Broker バージョン 8.0.0.5 オペレーティング・システム: AIX、HP-Itanium、Linux、Solaris、Windows、z/OS

製品の最新バージョンについては、IBM Integration Bus バージョン 9.0 をご覧ください。

動的 E メール・メッセージの作成

SMTP サーバー、受信者リスト、件名、本文、および複数の添付ファイルのすべてが実行時に決定される E メールを作成できます。

複数の添付ファイルのある E メールを作成するメッセージ・フローを作成できます。 1 つの添付ファイル、静的な件名、および静的な本文のある E メールを静的な受信者リストに送信するように EmailOutput ノードを構成するには、添付ファイル付きの E メールの送信を参照してください。

E メールの送信時に設定したノード・プロパティーは任意指定にでき、ローカル環境で指定した値、E メールの出力ヘッダー (EmailOutputHeader)、またはメッセージの本文によって実行時に指定変更できます。 この方式を使用するには、メッセージ・フロー内の前のノードでこれらの指定変更を構成しなければなりません。 E メールの本文のノード・プロパティーでテキストの値が指定されていない場合は、EmailOutput ノードに渡されたメッセージが使用されます。

以下の例では、ESQL (Compute ノードを使用) および Java™ (JavaCompute ノードを使用) で受信者、送信者、件名、SMTP サーバー、およびメッセージ本文の情報をセットアップする方法を示します。

Compute ノードの使用

この図は、MQInput ノード、Compute ノード、および EmailOutput ノードを使って動的 E メール・メッセージを生成するメッセージ・フローを示しています。
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;
E メールの本文として生成されるテキスト・ストリング内に空白文字 (改行 (NL)、復帰 (CR)、改行 (LF) 文字など) を記述するには、以下のコード行を追加します。
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);

JavaCompute ノードの使用

この図は、MQInput ノード、JavaCompute ノード、および EmailOutput ノードを使って動的 E メール・メッセージを生成するメッセージ・フローを示しています。
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); 	}

ローカル環境の使用

ローカル環境を使用して、SMTP サーバー接続情報と添付ファイルを指定変更するよう指定します。
ローカル環境 説明
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 式。 参照エレメントの値は添付ファイルの値として取得されます。
  • エレメントが BLOB の場合は添付ファイルです。
  • エレメントがテキストの場合は、メッセージ・ツリーまたは LocalEnvironment 内の別のエレメント に解決できるか確認してください。 解決できた場合は、そのエレメントを使用します。 解決できなかった場合は、このエレメントを添付ファイルとして追加します。
Destination.Email.Attachment.ContentType text/plain、text/html、および text/xml など、添付ファイルのタイプ。 (インターネット・メディア・タイプとも呼ばれる)。 ここでは任意の値を設定できます。
Destination.Email.Attachment.ContentName 添付ファイルの名前。
Destination.Email.Attachment.ContentEncoding 添付ファイルのエンコード。7bit、base64、または quoted-printable。
  • 7bit は ASCII テキストに使用されるデフォルト値です。
  • Base64 は英語以外の言語、またはバイナリー・データなど非 ASCII に使用されます。 この形式は読み取るのが困難な場合があります。
  • quoted-printable は Base64 の代替方式で、ほとんどのデータが ASCII で、一部に非 ASCII が含まれる場合に適しています。 この形式の方が読み取りは容易です。ASCII 部はエンコードされないため、エンコードをコンパクトに保つことができます。

E メール出力ヘッダーの使用

E メール出力ヘッダーを使用して、SMTP サーバー接続情報と添付ファイルを指定変更するよう指定します。 EmailOutputHeader はルートの子です。 このヘッダーで指定する値は、EmailOutput ノード上で設定した同等のプロパティーを指定変更します。 SMTP 出力ヘッダーを使用して、受信者などの E メール属性を指定します。
場所 説明
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 メールの件名。
特記事項 | 商標 | ダウンロード | ライブラリー | サポート | フィードバック

Copyright IBM Corporation 1999, 2014Copyright IBM Corporation 1999, 2014.

        
        最終更新:
        
        最終更新: 2015-02-28 17:46:12


タスク・トピックタスク・トピック | バージョン 8.0.0.5 | ac66340_