Author |
Message
|
diamondiona |
Posted: Wed Mar 18, 2015 7:48 am Post subject: EmailOutputNode MIME ERROR |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
Hello,
I have an error handling flow like:
EmailInputNode -> Catch Terminal -> ComputeNode -> EmailOutputNode
I used "SET OutputRoot = InputRoot" to propagate "MIME" content inside ComputeNode. But EmailOutputNode always throws Exception:
Exception whilst creating MIME message or getting the Message ID
Text:CHARACTER:Last child must be Parts or Data
Text:CHARACTER:MIME
If I use the following code to rebuild MIME tree, it works perfectly fine. Can someone please advise?
Code: |
CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
-- First part:
-- Create the body of the email.
-- The body of the email has the text 'This is the main body of the email.'.
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain; charset=us-ascii';
CREATE FIELD P1."Content-Transfer-Encoding" TYPE NameValue VALUE '8bit';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(CAST('This is the main body of the email.'
AS BLOB CCSID 1208));
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
-- Second part:
-- Create the attachment of an email.
-- The attachment is called 'attachment.txt' and contains the text 'This is an attachment.'.
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain; charset=us-ascii; name=attachment.txt';
CREATE FIELD P2."Content-Transfer-Encoding" TYPE NameValue VALUE '8bit';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(CAST('This is an attachment.' AS BLOB CCSID 1208)); |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 18, 2015 8:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
So when you copy InputRoot to OutputRoot, what is the name of the last child? _________________ MQ & Broker admin |
|
Back to top |
|
 |
diamondiona |
Posted: Wed Mar 18, 2015 9:19 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
The last name is "MIME". But if I built from scratch, the last child is also "MIME" parser. |
|
Back to top |
|
 |
diamondiona |
Posted: Wed Mar 18, 2015 9:29 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
Here is the message tree:
Code: |
Message
Properties
MessageSet:CHARACTER:
MessageType:CHARACTER:
MessageFormat:CHARACTER:
Encoding:INTEGER:273
CodedCharSetId:INTEGER:819
Transactional:BOOLEAN:false
Persistence:BOOLEAN:false
CreationTime:TIMESTAMP:java.util.GregorianCalendar[time=1426713606913,areFieldsSet=true,areAllFieldsSet=false,
lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,
lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,
startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,
endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,
ERA=?,YEAR=2015,MONTH=2,WEEK_OF_YEAR=?,
WEEK_OF_MONTH=?,DAY_OF_MONTH=18,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,
HOUR=5,HOUR_OF_DAY=17,MINUTE=20,SECOND=6,MILLISECOND=913,ZONE_OFFSET=?,DST_OFFSET=?]
ExpirationTime:INTEGER:-1
Priority:INTEGER:0
ReplyIdentifier:BLOB:[B@4ee04ee
ReplyProtocol:CHARACTER:UNKNOWN
Topic:UNKNOWN:null
ContentType:CHARACTER:multipart/mixed; boundary=_003_06860B00CA4C88469D17A3420F0DBE32015FE3D5F9pwat1inmbx02e_
IdentitySourceType:CHARACTER:
IdentitySourceToken:CHARACTER:
IdentitySourcePassword:CHARACTER:
IdentitySourceIssuedBy:CHARACTER:
IdentityMappedType:CHARACTER:
IdentityMappedToken:CHARACTER:
IdentityMappedPassword:CHARACTER:
IdentityMappedIssuedBy:CHARACTER:
EmailOutputHeader
To:CHARACTER:ErrorMail.NonProd@economical.com
From:CHARACTER:Diamond Li <diamond.li@economical.com>
Subject:CHARACTER:FW: TEST for ATTACHMENT
MIME
Content-Type:CHARACTER:multipart/mixed; boundary=_003_06860B00CA4C88469D17A3420F0DBE32015FE3D5F9pwat1inmbx02e_
Content-ID:CHARACTER:new MIME document
Parts
Part
Content-Type:CHARACTER:text/html; charset="Windows-1252"
Content-Transfer-Encoding:CHARACTER:quoted-printable
Data
BLOB
BLOB:BLOB:[B@1a1e1a1e
Part
Content-Type:CHARACTER:message/rfc822
Content-Disposition:CHARACTER:attachment
MIME
Content-Type:CHARACTER:multipart/related; boundary=_002_6C60615AEDDC3143B23C40648976928401600A52A7pwat1inmbx02e_; type="text/html"
Parts
Part
Content-Type:CHARACTER:text/html; charset="us-ascii"
Data
BLOB
BLOB:BLOB:[B@401a401a
Part
Content-Type:CHARACTER:image/png; name="image001.png"
Content-Description:CHARACTER:image001.png
Content-Disposition:CHARACTER:inline; filename="image001.png"; size=279310;creation-date="Tue, 17 Mar 2015 17:21:59 GMT";modification-date="Tue, 17 Mar 2015 17:21:59 GMT"
Content-ID:CHARACTER:<image001.png@01D060B5.57E1FE80>
Content-Transfer-Encoding:CHARACTER:base64
Data
BLOB
BLOB:BLOB:[B@567e567e
Part
Content-Type:CHARACTER:message/rfc822
Content-Disposition:CHARACTER:attachment
MIME
Content-Type:CHARACTER:multipart/related; boundary=_002_6C60615AEDDC3143B23C40648976928401600A5271pwat1inmbx02e_; type="text/html"
Parts
Part
Content-Type:CHARACTER:text/html; charset="us-ascii"
Data
BLOB
BLOB:BLOB:[B@67306730
Part
Content-Type:CHARACTER:image/png; name="image001.png"
Content-Description:CHARACTER:image001.png
Content-Disposition:CHARACTER:inline; filename="image001.png"; size=279310;creation-date="Tue, 17 Mar 2015 17:03:57 GMT";modification-date="Tue, 17 Mar 2015 17:03:57 GMT"
Content-ID:CHARACTER:<image001.png@01D060B2.D2CF71C0>
Content-Transfer-Encoding:CHARACTER:base64
Data
BLOB
BLOB:BLOB:[B@22ae22ae |
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 18, 2015 10:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What has me confused is the whole structure as you describe it:
Code: |
MIME
Parts
Part
Part
[b]MIME[/b]
Parts
Part
Part
Part
[b]MIME[/b]
Parts
Part
Part |
Why the imbricated mime parts? Shouldn't that all be part of a Data.BLOB?
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
diamondiona |
Posted: Wed Mar 18, 2015 10:27 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
The whole structure is described by EmailInputNode. Then it passed down to my "Compute" node. The MIME parts should be imbricate. You can play with EmailInput Node and have fun
 |
|
Back to top |
|
 |
nelson |
Posted: Wed Mar 18, 2015 5:58 pm Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 19, 2015 4:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Looks like the whole embedded structure references attached emails... like
Code: |
MIME
Parts
Part (body)
Data
BLOB
BLOB (body of email)
Part (attachments)
MIME (Wrong one Parts-Part level too high!)
Parts
Part (body of attached email)
Data
BLOB
BLOB |
Note that the Part tag carrying the embedded email can never be the first Part in your hierarchy...
So if the node is protesting / or the email system is, why not add an additional Part - Data - BLOB-BLOB with an empty blob? so as to conform?
This way the last child is Part-Data and not Part-MIME and more in line with displaying images referenced in the mail's body... If you follow Nelson's link on developerworks you can get the structure in more details
Note that the outer Parts -Part line never has a MIME attached. It is only the second level that does... Food for thoughts...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
diamondiona |
Posted: Thu Mar 19, 2015 6:38 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
It 's working after I added the following line to the end of my message:
Code: |
SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);
|
But from IBM Example, the last child isn't BLOB and it works in my case. The only difference is the MIME tree in my computer node is propagated from EmailInputNode.
Here is the code from IBM infoCenter:
Code: |
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 = 'Dynamic MIME message in ESQL.';
-- Add SMTP server information to the LocalEnvironment
SET OutputLocalEnvironment.Destination.Email.SMTPServer ='<smtp.server:port>';
-- Create a new MIME message body, which will be sent as the main text of the email,
-- including an attachment.
CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;
-- Create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
-- First part:
-- Create the body of the email.
-- The body of the email has the text 'This is the main body of the email.'.
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain; charset=us-ascii';
CREATE FIELD P1."Content-Transfer-Encoding" TYPE NameValue VALUE '8bit';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(CAST('This is the main body of the email.'
AS BLOB CCSID 1208));
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
-- Second part:
-- Create the attachment of an email.
-- The attachment is called 'attachment.txt' and contains the text 'This is an attachment.'.
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain; charset=us-ascii; name=attachment.txt';
CREATE FIELD P2."Content-Transfer-Encoding" TYPE NameValue VALUE '8bit';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(CAST('This is an attachment.' AS BLOB CCSID 1208));
RETURN TRUE;
END;
|
|
|
Back to top |
|
 |
diamondiona |
Posted: Fri Mar 20, 2015 11:20 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
Hello,
I just checked the result, the good part is I can get the email successfully. The bad part is there is no attachments in the email. It means MessageBroker ignored entire MIME tree and parsed BLOB only. The email I got is
"This is the new text for the body of the email"
Set by
Code: |
SET OutputRoot.BLOB.BLOB = CAST('This is the new text for the body of the email.' AS BLOB CCSID 1208);
|
Also, I tried to add " Part - Data - BLOB-BLOB with an empty blob". EmailOutput Node throws exception. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Mar 20, 2015 11:35 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I think you have to get back to the developerworks article and really understand how a tree with attachments is supposed to get built.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
diamondiona |
Posted: Fri Mar 20, 2015 11:45 am Post subject: |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
Since my input node is EmailInput node, I tried to cut corner and reuse the MIME tree in compute node. It looks like I need dig deeper. |
|
Back to top |
|
 |
nelson |
Posted: Fri Mar 20, 2015 1:00 pm Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
diamondiona wrote: |
Since my input node is EmailInput node, I tried to cut corner and reuse the MIME tree in compute node. It looks like I need dig deeper. |
There's a difference between attachments received and attachments sent.
Please take a look at the EmailOutput node documentation. In order to handle outbound attachments you need to populate the OutputLocalEnvironment.Destination.Email.Attachment tree... |
|
Back to top |
|
 |
diamondiona |
Posted: Wed Apr 22, 2015 6:32 am Post subject: This is a product defect |
|
|
Acolyte
Joined: 19 Jun 2014 Posts: 50
|
IBM has confirmed that this is a product defect and provided a emergency fix to me. I verified the MIME serialization issue has been fixed. By the way, this defect exists all versions, 7.0, 8.0, 9.0, and 10.0. |
|
Back to top |
|
 |
|