Author |
Message
|
jennifer.jose26 |
Posted: Thu Dec 02, 2010 6:28 am Post subject: CREATING MIME MESSAGE |
|
|
Newbie
Joined: 02 Dec 2010 Posts: 3
|
hey,
Does anybody have sample running code to create MIME messages ?
I have the requirement for reading a file that can be a pdf,mp3 etc from a folder , convert it into MIME message with multiple parts of say 10kb each and sending as a reply through HTTP Reply Node...
I managed to get some sample code but seems it doesnt work -
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-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);
RETURN TRUE;
Can someone help ? |
|
Back to top |
|
 |
veda |
Posted: Thu Dec 02, 2010 6:49 am Post subject: Re: CREATING MIME MESSAGE |
|
|
Novice
Joined: 01 Dec 2010 Posts: 24
|
jennifer.jose26 wrote: |
hey,
Does anybody have sample running code to create MIME messages ?
I have the requirement for reading a file that can be a pdf,mp3 etc from a folder , convert it into MIME message with multiple parts of say 10kb each and sending as a reply through HTTP Reply Node...
I managed to get some sample code but seems it doesnt work -
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-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);
RETURN TRUE;
Can someone help ? |
When you create a new MIME message, you have to make sure to set the ContentType property ! Did you try doing so?
SET OutputRoot.Properties.ContentType = 'text/plain'; |
|
Back to top |
|
 |
Vitor |
Posted: Thu Dec 02, 2010 7:10 am Post subject: Re: CREATING MIME MESSAGE |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jennifer.jose26 wrote: |
I managed to get some sample code but seems it doesnt work - |
Doesn't work how? Abends? Produces output in the wrong format? Causes lightning to strike the tree outside your window?
Better information, better advice.
2 other points:
- Don't double post. If you think you've posted in the wrong place, ask for the post to be moved.
- Contain code in the proper code tags. It makes it much easier to read and follow _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Dec 02, 2010 7:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
PARSE() with DOMAIN('BLOB') is a no op, almost assuredly. If nothing else, it makes your code more confusing to read - but shouldn't actually be causing an issue. |
|
Back to top |
|
 |
jennifer.jose26 |
Posted: Thu Dec 02, 2010 7:57 pm Post subject: |
|
|
Newbie
Joined: 02 Dec 2010 Posts: 3
|
Vitor,
Thanks for your advise. But there are better ways of making people aware of something than being rude. We all understand that you are an expert and thats why we are seeking your help. I really dont see any point in flaunting your knowledge by being rude to other.
Anyways, it would be great if you can help me understand the issue.
Problem -
1. the code code will break the file in two parts. But at ruintime i wanna give the flexibility of deciding how many parts the file has to be broken to based on some boundary condition, say "after writing 10KB records".
I have no idea on how to fit this logic into the existing code which is -
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();
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-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';
CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;
CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);
CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];
CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);
RETURN TRUE;
END; |
|
Back to top |
|
 |
harish_td |
Posted: Thu Dec 02, 2010 9:59 pm Post subject: |
|
|
Master
Joined: 13 Feb 2006 Posts: 236
|
I would ask these questions to myself.
Is my Input message indeed blob? (not because someone told me it is BLOB)
What is the value that gets saved after the below statement executed?
Code: |
DECLARE newBlob BLOB InputRoot.BLOB.BLOB; |
How am i splitting the incoming large data into smaller chunks?
If my input is BLOB, why should i re-parse that data as BLOB in the output?
What happens when i hard code the statement?
Code: |
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE('HELLO WORLD',InputRoot.Properties.Encoding,InputRoot.Properties.CodedCharSetId); |
My output message DOMAIN would always be BLOB; Why would i have to declare so many BLOB domain elements? |
|
Back to top |
|
 |
kimbert |
Posted: Fri Dec 03, 2010 2:11 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
it would be great if you can help me understand the issue. |
I suggest that you start by answering Vitor's questions, and doing what he suggested re: formatting your source code. |
|
Back to top |
|
 |
|