Author |
Message
|
KoGor |
Posted: Fri Apr 25, 2008 7:03 am Post subject: How to send e-mail by E-Mail node ? |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Hi All!
I'm using WMB6.1 on AIX. I'm trying to send e-mail notification. The flow is rather simple: MQ_IN->Compute->EMAIL_Output
I get some info from the input message and want to put it to the e-mail body. I don't want to use attachments - email text message enough for this data. When I set "MessageText" property in Email node everything works. But when I'm trying to put into email body dynamicaly content of my message there is an exception.
This is my code I used for testing:
Code: |
SET OutputRoot.Properties = InputRoot.Properties;
SET OutputRoot.MQMD = InputRoot.MQMD;
CREATE LASTCHILD OF OutputRoot TYPE Name NAME 'EmailOutputHeader';
SET OutputRoot.EmailOutputHeader.To = 'user1@localdomain.org';
SET OutputRoot.EmailOutputHeader.From = 'user2@localdomain.org';
SET OutputRoot.EmailOutputHeader.Subject = 'Subject';
SET OutputRoot.EmailOutputHeader.Message = 'Body';
SET OutputLocalEnvironment.Destination.Email.BodyContentType = 'text/plain';
SET OutputLocalEnvironment.Destination.Email.SMTPServer = '192.168.48.84'; |
The error:
Code: |
Text:CHARACTER:Exception whilst writing the message
Insert
Type:INTEGER:5
Text:CHARACTER:com.ibm.broker.emailnodes.EmailOutputNode : <com.ibm.broker.plugin.MbRecoverableException class:com.ibm.broker.emailnodes.EmailOutputNode method:addMessageTextInformationToEmail() source:BIPv610 key:4458 >
at com.ibm.broker.emailnodes.EmailOutputNode.throwRecoverableException(EmailOutputNode.java:1810)
at com.ibm.broker.emailnodes.EmailOutputNode.emailOutputNodeRecoverableException(EmailOutputNode.java:1715)
at com.ibm.broker.emailnodes.EmailOutputNode.addMessageTextInformationToEmail(EmailOutputNode.java:496)
at com.ibm.broker.emailnodes.EmailOutputNode.sendBasicEmail(EmailOutputNode.java:423)
at com.ibm.broker.emailnodes.EmailOutputNode.sendData(EmailOutputNode.java:348)
at com.ibm.broker.plugin.MbOutputTemplateNode.sendData(MbOutputTemplateNode.java:47)
|
What did I wrong? I have read all documentation but hadn't any idea what to try next.
Thank you in advance! |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Apr 25, 2008 7:21 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You aren't showing where you actually set the body of the document.
For "text", I'd expect you'd either be using OutputRoot.MRM or OutputRoot.BLOB.BLOB.
I don't think the EmailOutputHeader.Message is a valid field.
Also, you either didn't capture or didn't post the full exception, so there might be something else wrong that isn't visible. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Apr 25, 2008 8:01 am Post subject: Here is how I did it... |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
I installed the EMAIL sample supplied with V6.1 and then put a trace node before the EMAIL Node.
I traced
${Root}
${LocalEnvironment}
I then saw the exact structures needed to get the emails sent.
I was then able to recreate the stuff in my own flows.
A little hint.
I found it better to start with a totally clean ROOT.
1) Save the INputRoot into the Environment
2) Create a new properties folder. You don't have to set anything
3) Create the EmailHeader Folder.
4) format the EmailHeader
5) format the OutputRoot.BLOB.BLOB
6) Format the OutputLocalEnvironment
Send the Email
Then, finally if you have to,
7) Restore the complete Root tree from what you saved in the Environment.
I have this working now and are using it to send amongst other things Java Client Exception Messages from Lotus Expeditor via MQe. The Stack trace is sent as an attachment.
Good Luck.
/S _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
KoGor |
Posted: Tue Apr 29, 2008 12:32 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
2smdavies99
Thanks for the trace idea. Unfortunately it didn't help to trace in what place EMAIL node put its message variable. But after few try I managed to send my string as email body.
As said jefflowrey (thanks to you !) I filled the OutputRoot.BLOB.BLOB. So I set OutputRoot.BLOB.BLOB to the BLOB value and it works. So code now looks like:
Code: |
SET OutputRoot.Properties = InputRoot.Properties;
SET OutputRoot.MQMD = InputRoot.MQMD;
CREATE LASTCHILD OF OutputRoot TYPE Name NAME 'EmailOutputHeader';
SET OutputRoot.EmailOutputHeader.To = 'user1@localdomain.org';
SET OutputRoot.EmailOutputHeader.From = 'user2@localdomain.org';
SET OutputRoot.EmailOutputHeader.Subject = 'Subject';
SET OutputLocalEnvironment.Destination.Email.BodyContentType = 'text/plain';
SET OutputLocalEnvironment.Destination.Email.SMTPServer = '192.168.48.84';
CREATE LASTCHILD OF OutputRoot DOMAIN 'BLOB';
SET OutputRoot.BLOB.BLOB = X'3c3f';
|
But then I faced with the other problem. I want to create email message body dynamically. It should look like :
'There is an error code=' || ErrCode || ' in node ' || FlowNode and etc...
So I have to cast it to the BLOB. When I try to cast with command:
Code: |
CREATE LASTCHILD OF Environment.Variables.MailText DOMAIN 'XMLNSC' Name 'Body' VALUE 'There is an error code....';
SET OutputRoot.BLOB.BLOB = ASBITSTREAM(Environment.Variables.MailText.Body OPTIONS FolderBitStream CCSID 1208 );
|
it works but it also add tags <body> to my string. So I don't want them in my message body - just my string. Now I can't find another way to convert string to BLOB.
Please could you advise if there is any way to solve my problem? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 29, 2008 1:28 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You don't need DOMAIN('XMLNSC').
You don't even really need to use Environment.Variables.
You can just create a CHARACTER variable, and set that to your string data, and then cast that.
Or you can just use Environment.Variables.Body without making it in the XMLNSC domain. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
KoGor |
Posted: Tue Apr 29, 2008 1:43 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
Hi, jefflowrey! Thanks for answer.
I tried this code:
Code: |
DECLARE MailText CHARACTER 'test';
CREATE LASTCHILD OF OutputRoot DOMAIN 'BLOB';
SET OutputRoot.BLOB.BLOB = CAST(MailText AS BLOB); |
And I got thi exception:
Code: |
ExceptionList
RecoverableException
File:CHARACTER:/build/S610_P/src/DataFlowEngine/ImbDataFlowNode.cpp
Line:INTEGER:739
Function:CHARACTER:ImbDataFlowNode::createExceptionList
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:SDSv2SendAlarmFlow#FCMComposite_1_3
Label:CHARACTER:SDSv2SendAlarmFlow.MQIN_HF_Error
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Node throwing exception
RecoverableException
File:CHARACTER:/build/S610_P/src/DataFlowEngine/ImbComputeNode.cpp
Line:INTEGER:464
Function:CHARACTER:ImbComputeNode::evaluate
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:SDSv2SendAlarmFlow#FCMComposite_1_6
Label:CHARACTER:SDSv2SendAlarmFlow.Compute
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Caught exception and rethrowing
RecoverableException
File:CHARACTER:/build/S610_P/src/DataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp
Line:INTEGER:602
Function:CHARACTER:SqlStatementGroup::execute
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:SDSv2SendAlarmFlow#FCMComposite_1_6
Label:CHARACTER:SDSv2SendAlarmFlow.Compute
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:2488
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:.SDSv2SendAlarmFlow_Compute.Main
Insert
Type:INTEGER:5
Text:CHARACTER:18.3
Insert
Type:INTEGER:5
Text:CHARACTER:SET OutputRoot.BLOB.BLOB = CAST(MailText AS BLOB);
RecoverableException
File:CHARACTER:/build/S610_P/src/DataFlowEngine/ImbRdl/ImbRdlTypeCast.cpp
Line:INTEGER:339
Function:CHARACTER:SqlTypeCast::evaluate
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:2521
Text:CHARACTER:Error casting from %3 to %4
Insert
Type:INTEGER:5
Text:CHARACTER:.SDSv2SendAlarmFlow_Compute.Main
Insert
Type:INTEGER:5
Text:CHARACTER:18.30
Insert
Type:INTEGER:5
Text:CHARACTER:'test'
Insert
Type:INTEGER:5
Text:CHARACTER:BLOB
RecoverableException
File:CHARACTER:/build/S610_P/src/CommonServices/ImbValue.cpp
Line:INTEGER:616
Function:CHARACTER:ImbValue::fromCharacter
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPv610
Severity:INTEGER:3
Number:INTEGER:2590
Text:CHARACTER:String is not of correct form for byte array. Must consist of only 0..9,a..f,A..Z
Insert
Type:INTEGER:5
Text:CHARACTER:test |
When I tried to remove DOMAIN 'XMLNSC' from ASBITSTREAM:
Code: |
CREATE LASTCHILD OF Environment.Variables Name 'Body' VALUE 'test';
CREATE LASTCHILD OF OutputRoot DOMAIN 'BLOB';
SET OutputRoot.BLOB.BLOB = ASBITSTREAM(Environment.Variables.Body OPTIONS FolderBitStream CCSID 1208 );
|
I got an empty OutputRoot.BLOB.BLOB. So as I said I haven't find any way to convert string to blob.
Or may be I didn't understand what you had meant? |
|
Back to top |
|
 |
gregop |
Posted: Tue Apr 29, 2008 3:24 am Post subject: |
|
|
Voyager
Joined: 24 Nov 2006 Posts: 81
|
[/quote]SET OutputRoot.BLOB.BLOB = CAST(MailText AS BLOB);
Quote: |
You'll need to specify the CCSID.
SET OutputRoot.BLOB.BLOB = CAST(MailText AS BLOB CCSID InputRoot.Properties.CodedCharSetId) ; |
|
|
Back to top |
|
 |
KoGor |
Posted: Tue Apr 29, 2008 4:10 am Post subject: |
|
|
Voyager
Joined: 09 Nov 2005 Posts: 81 Location: Moscow,Russia.
|
gregop Thank you! It works now! I overlooked this facility for CAST because use it rarely. But I've read CAST description careful now and understand that it much more usefull than I thought
But now I have another problem
I'm trying to encode string in Russian as Unicode:
Code: |
DECLARE MailText CHARACTER 'тест';
SET OutputRoot.BLOB.BLOB = CAST(MailText AS BLOB CCSID 1208);
|
My text is not displayed correct in email client. I got this in letter's MIME header:
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: base64
I think to display email body correct charset should be UTF8 or CP1251, but I didn't find any settings for email node. Do anybody know what settings WMB or may be EMAIL node use to encode email body? I tried to change OS setting - didn't help. Is there a way to set it manually?
Thank you in advance! |
|
Back to top |
|
 |
shantanu1621 |
Posted: Mon May 25, 2015 3:01 am Post subject: |
|
|
Novice
Joined: 24 May 2013 Posts: 10
|
Quote: |
I think to display email body correct charset should be UTF8 |
I think you can try :
Outputlocalenvironment.Destination.Email.BodyContentType = 'text/html;charset=utf-8'; |
|
Back to top |
|
 |
|