Author |
Message
|
kayhansefat |
Posted: Mon Feb 26, 2007 8:06 am Post subject: IA07 Sendmail attachment please help |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
I can successfully use the sendmail plugin to send emails but I cant for the life of me get it to include an attachment. All I want to do is include an xml attachment for example test.xml. I cant even get the examples in the tutorial for the plugin to work including:
Code: |
<Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body><Line>This is line1</Line><Line>(See attached file: test.xml)</Line></Body><EncodingBase64 ContentType="application/octet-stream" Name="test.xml"><![CDATA[ SGVsbG8gS2F5aGFu ]]></EncodingBase64></Message> |
Code: |
<Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body><Line>This is line1</Line><Line>(See attached file: test.txt)</Line></Body><Encoding7Bit ContentType="text/plain" Name="test.txt"><![CDATA[ Hello Kayhan! ]]></Encoding7Bit></Message> |
Code: |
<Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body><Line>This is line1</Line><Line>(See attached file: test.xml)</Line></Body><EncodingBase64 ContentType="text/xml" Name="test.xml"/></Message> |
Quote: |
<Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body><Line>This is line1</Line><Line>(See attached file: test.xml)</Line></Body><EncodingBase64 ContentType="text/plain" Name="test.xml"><![CDATA[ SGVsbG8gS2F5aGFu ]]></EncodingBase64></Message> |
All I get from them all is ONLY what is inluded in the body text (if any for that example). I have tried fidlding with the settings of the sendmail node, at the moment it is set to UTF-8, Base64 and MIME - unticked.
I am pretty sure that mails go locally through the server using the sendmail command, then onto the smtp mail server we have here so I am wondering if that is the reason why.
I have looked pain stakingly though the forums on here but cant seem to find an example that is guarenteed to work that I can test it with. Any advice would be great, many thanks. |
|
Back to top |
|
 |
au@kosa |
Posted: Tue Feb 27, 2007 3:05 am Post subject: |
|
|
 Centurion
Joined: 04 Jan 2007 Posts: 103 Location: pune
|
|
Back to top |
|
 |
kayhansefat |
Posted: Thu Mar 01, 2007 1:30 am Post subject: |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
Yeah I have checked those posts, followed them and still no success. Let me just descibe what I have and what is happening. I have:
MQInput --> Trace1 --> Compute --> Trace2 --> SendMailPlugin --> Trace3
The domain for the MQInput is set to XML. I put the following message on the input queue:
Code: |
<Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body>(See attached file: attachment.xml)</Body><EncodingBase64 ContentType="text/plain" Name="attachment.xml"/></Message> |
I get the email but with no attachment. Trace1 outputs:
Code: |
START HERE
(
(0x01000000):Properties = (
(0x03000000):MessageSet = ''
(0x03000000):MessageType = ''
(0x03000000):MessageFormat = ''
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Transactional = TRUE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2007-03-01 09:11:57.390'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'MQ'
(0x03000000):Topic = NULL
(0x03000000):ContentType = ''
)
(0x01000000):MQMD = (
(0x03000000):SourceQueue = 'SMTP.TEST'
(0x03000000):Transactional = TRUE
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Format = 'MQSTR '
(0x03000000):Version = 2
(0x03000000):Report = 0
(0x03000000):MsgType = 8
(0x03000000):Expiry = -1
(0x03000000):Feedback = 0
(0x03000000):Priority = 0
(0x03000000):Persistence = 0
(0x03000000):MsgId = X'414d51205742524b365f44454641554ca5d7e24502e81e20'
(0x03000000):CorrelId = X'000000000000000000000000000000000000000000000000'
(0x03000000):BackoutCount = 0
(0x03000000):ReplyToQ = ' '
(0x03000000):ReplyToQMgr = 'WBRK6_DEFAULT_QUEUE_MANAGER '
(0x03000000):UserIdentifier = 'wbiadmin '
(0x03000000):AccountingToken = X'0335313400000000000000000000000000000000000000000000000000000006'
(0x03000000):ApplIdentityData = ' '
(0x03000000):PutApplType = 6
(0x03000000):PutApplName = 'java '
(0x03000000):PutDate = DATE '2007-03-01'
(0x03000000):PutTime = GMTTIME '09:11:57.390'
(0x03000000):ApplOriginData = ' '
(0x03000000):GroupId = X'000000000000000000000000000000000000000000000000'
(0x03000000):MsgSeqNumber = 1
(0x03000000):Offset = 0
(0x03000000):MsgFlags = 0
(0x03000000):OriginalLength = -1
)
(0x01000010):XML = (
(0x01000000):Message = (
(0x01000000):From = (
(0x02000000): = 'test@test.com'
)
(0x01000000):To = (
(0x02000000): = 'test@test.com'
)
(0x01000000):Subject = (
(0x02000000): = 'This is the subject'
)
(0x01000000):Body = (
(0x02000000): = '(See attached file: attachment.xml)'
)
(0x01000000):EncodingBase64 = (
(0x03000000):ContentType = 'text/plain'
(0x03000000):Name = 'attachment.xml'
)
)
)
)
END HERE |
Trace2 outputs:
Code: |
START HERE
(
(0x01000000):Properties = (
(0x03000000):MessageSet = ''
(0x03000000):MessageType = ''
(0x03000000):MessageFormat = ''
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Transactional = TRUE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2007-03-01 09:11:57.390'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'MQ'
(0x03000000):Topic = NULL
(0x03000000):ContentType = ''
)
(0x01000000):MQMD = (
(0x03000000):SourceQueue = 'SMTP.TEST'
(0x03000000):Transactional = TRUE
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 1208
(0x03000000):Format = 'MQSTR '
(0x03000000):Version = 2
(0x03000000):Report = 0
(0x03000000):MsgType = 8
(0x03000000):Expiry = -1
(0x03000000):Feedback = 0
(0x03000000):Priority = 0
(0x03000000):Persistence = 0
(0x03000000):MsgId = X'414d51205742524b365f44454641554ca5d7e24502e81e20'
(0x03000000):CorrelId = X'000000000000000000000000000000000000000000000000'
(0x03000000):BackoutCount = 0
(0x03000000):ReplyToQ = ' '
(0x03000000):ReplyToQMgr = 'WBRK6_DEFAULT_QUEUE_MANAGER '
(0x03000000):UserIdentifier = 'wbiadmin '
(0x03000000):AccountingToken = X'0335313400000000000000000000000000000000000000000000000000000006'
(0x03000000):ApplIdentityData = ' '
(0x03000000):PutApplType = 6
(0x03000000):PutApplName = 'java '
(0x03000000):PutDate = DATE '2007-03-01'
(0x03000000):PutTime = GMTTIME '09:11:57.390'
(0x03000000):ApplOriginData = ' '
(0x03000000):GroupId = X'000000000000000000000000000000000000000000000000'
(0x03000000):MsgSeqNumber = 1
(0x03000000):Offset = 0
(0x03000000):MsgFlags = 0
(0x03000000):OriginalLength = -1
)
(0x01000010):XML = (
(0x01000000):Message = (
(0x01000000):From = (
(0x02000000): = 'test@test.com'
)
(0x01000000):To = (
(0x02000000): = 'test@test.com'
)
(0x01000000):Subject = (
(0x02000000): = 'This is the subject'
)
(0x01000000):Body = (
(0x02000000): = '(See attached file: attachment.xml)'
)
(0x01000000):EncodingBase64 = (
(0x03000000):ContentType = 'text/plain'
(0x03000000):Name = 'attachment.xml'
)
)
)
(0x01000000):BLOB = (
(0x03000000):BLOB = X'3c4d6573736167653e3c46726f6d3e6b617968616e2e736566617440726263682e6e68732e756b3c2f46726f6d3e3c546f3e6b617968616e2e73656661744072'... (data of len 239 truncated)'
)
)
END HERE |
Trace3 out of the 'out' terminal of the plugin node has the same output as Trace2.
Now the compute node has the code (from the released doc for the node):
Code: |
SET OutputRoot = InputRoot;
SET OutputRoot."BLOB"."BLOB" = BITSTREAM(InputBody); |
Now I am concerned that the BLOB data here contains all of the XML part of the message (the InputBody) not the data that I want to be encoded for the attachment. If that is so, is the code above incorrect? |
|
Back to top |
|
 |
sunny_30 |
Posted: Thu Mar 01, 2007 7:51 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
I am using the sendmailplugin node for my flows and the attachments part is working fine.
This is how I have it:--
input -->> compute1 -->> compute2 -->> sendmail
I am using two computes one after the other in my flow as I have some other processing to do apart from the below. Not to confuse you, but only a single compute can be used that has the below logic..
In the compute1:
Build the Output.XML.
SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM(OutputRoot.XML OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
later I set the OutputRoot.XML to null.
In the compute2:
SET OutputRoot.XML.Message."From" = SenderMailId;
SET OutputRoot.XML.Message."To" = RecipientMailId;
SET OutputRoot.XML.Message.Subject = Subject;
SET OutputRoot.XML.Message.Body = 'Please get the XML-Attachment';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)ContentType = 'text/xml';
SET OutputRoot.BLOB.BLOB = InputRoot.BLOB.BLOB;
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)Name = NameOfTheAttchmentFile;
For the sendmailplugin node, I set the following properties:
Fill up the SMTP details.
In the MIME section, I select(tick) the MIME & the transfer-encoding to BASE64.
If its done the above way, it shd work as it is working for me.
Hope this helps!
Last edited by sunny_30 on Thu Mar 01, 2007 9:51 am; edited 3 times in total |
|
Back to top |
|
 |
kayhansefat |
Posted: Thu Mar 01, 2007 8:35 am Post subject: |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
sunny_30, thanks for posting. Due to my (lack of) knowledge I am unable to see where/how you pass in the data that is to be the attchment, is that built in the "SET OutputRoot.BLOB.BLOB" part in the first compute node?
Does your input node not have the xml parser assigned to it? Mine does therefore the message coming into the compute node1 already has the OutRoot.XML tree created, am I right?!
I wish the message that is put on the queue to "contain" the attachment data, subject,recepient etc in some way that I dont have to retrieve it in this flow. |
|
Back to top |
|
 |
sunny_30 |
Posted: Thu Mar 01, 2007 9:05 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
Read the below...
Last edited by sunny_30 on Thu Mar 01, 2007 9:45 am; edited 2 times in total |
|
Back to top |
|
 |
sunny_30 |
Posted: Thu Mar 01, 2007 9:39 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
sunny_30 wrote: |
Hey Kay..
If your input node is set to XML, you will have the InputRoot.XML created. You will not have the OutputRoot set until you build it / copy the message from Input to Output.
Yes in my earlier posted example, I was passing the attachment in the OutputRoot.BLOB.BLOB to the next compute. I was building the Attachment-XML-data in the OutputRoot.XML( you can also use an environment-tree or some row datatype to hold the tree instead). Then later in the same compute, I am converting it to the BLOB type and clearing off the XML message tree I built. In the next compute I am adding the header details for the mail and passing on the BLOB data out as is.
The whole logic is that when you to convert the XML-attachment message to BLOB before you pass it to the sendmail node, then the node reads the BLOB data and creates the attachment out of it. Alter the MIME settings as I posted earlier.
You can use just one compute as follows:--
input -->> compute -->> sendmail
In the compute:
SET OutputRoot.XML.Message."From" = SenderMailId (read from InputRoot)
SET OutputRoot.XML.Message."To" = RecipientMailId (read from InputRoot)
SET OutputRoot.XML.Message.Subject = Subject (read from InputRoot)
SET OutputRoot.XML.Message.Body = 'Please get the XML-Attachment or whatever';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)ContentType = 'text/xml';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)Name = NameOfTheAttchmentFile.xml;
SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM( The subtree part of the InputRoot.XML you need to use as the attachment message OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
Get whatever XML part you need to use for the attachment message from the InputBody / InputRoot.XML and send it out as the BLOB, alongwith the mail message headers (to, from etc) as Output in XML.
I hope things are clear.
|
Last edited by sunny_30 on Fri Mar 02, 2007 5:59 am; edited 2 times in total |
|
Back to top |
|
 |
kayhansefat |
Posted: Fri Mar 02, 2007 2:13 am Post subject: |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
Ok thanks I have played around with it a bit and attempting to include the attachment data in an additional xml attribute (Attachment) so I put on the queue:
Code: |
Message><From>test@test.com</From><To>test@test.com</To><Subject>This is the subject</Subject><Body>(See attached file: attachment.xml)</Body><EncodingBase64 ContentType="text/plain" Name="attachment.xml"/><Attachment>Hello Kayhan, can you see this?</Attachment></Message> |
And in my compute node is:
Code: |
SET OutputRoot.XML.Message."From" = 'test@test.com';
SET OutputRoot.XML.Message."To" = 'test@test.com';
SET OutputRoot.XML.Message.Subject = 'This is the subject';
SET OutputRoot.XML.Message.Body = 'Can you see the attachment?';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)ContentType = 'text/xml';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)Name = 'attachment.xml';
--SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM(InputRoot.XML.Message.Attachment OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding); |
However the OutputRoot.BLOB.BLOB is not getting parsed with the data in the Attachment field, I dont think I am setting it right.
Does it make sense to you to do it this way? |
|
Back to top |
|
 |
sunny_30 |
Posted: Fri Mar 02, 2007 8:55 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
Try this:
Quote: |
SET OutputRoot.XML = InputRoot.XML.Message.Attachment;
SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM(OutputRoot.XML OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
SET OutputRoot.XML = NULL;
CREATE PREVIOUSSIBLING OF OutputRoot.BLOB DOMAIN 'XML';
SET OutputRoot.XML.Message."From" = 'test@test.com';
SET OutputRoot.XML.Message."To" = 'test@test.com';
SET OutputRoot.XML.Message.Subject = 'This is the subject';
SET OutputRoot.XML.Message.Body = 'Can you see the attachment?';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)ContentType = 'text/xml';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)Name = 'attachment.xml'; |
And also for the sendmailplugin node, set the following properties:
Fill up the SMTP details.
In the MIME section, select(tick) the MIME & the transfer-encoding to BASE64.
Read my previous post again, I edited it to make things more clear.. |
|
Back to top |
|
 |
kayhansefat |
Posted: Mon Mar 05, 2007 1:50 am Post subject: |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
Ok, something in the compute node is causing the message to come out of the failure terminal. I have put a trace node on it and printed out the exception list:
Code: |
(
(0x01000000):RecoverableException = (
(0x03000000):File = '/build/S600_P/src/DataFlowEngine/ImbDataFlowNode.cpp'
(0x03000000):Line = 616
(0x03000000):Function = 'ImbDataFlowNode::createExceptionList'
(0x03000000):Type = 'ComIbmComputeNode'
(0x03000000):Name = 'WorkFlow#FCMComposite_1_10'
(0x03000000):Label = 'WorkFlow.Compute'
(0x03000000):Catalog = 'BIPv600'
(0x03000000):Severity = 3
(0x03000000):Number = 2230
(0x03000000):Text = 'Node throwing exception'
(0x01000000):RecoverableException = (
(0x03000000):File = '/build/S600_P/src/DataFlowEngine/ImbRdl/ImbRdlStatementGroup.cpp'
(0x03000000):Line = 589
(0x03000000):Function = 'SqlStatementGroup::execute'
(0x03000000):Type = 'ComIbmComputeNode'
(0x03000000):Name = 'WorkFlow#FCMComposite_1_10'
(0x03000000):Label = 'WorkFlow.Compute'
(0x03000000):Catalog = 'BIPv600'
(0x03000000):Severity = 3
(0x03000000):Number = 2488
(0x03000000):Text = 'Error detected, rethrowing'
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = '.WorkFlow_Compute.Main'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = '7.3'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM(OutputRoot.XML OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);'
)
(0x01000000):ParserException = (
(0x03000000):File = '/build/S600_P/src/MTI/MTIforBroker/GenXmlParser2/XmlImbParser.cpp'
(0x03000000):Line = 380
(0x03000000):Function = 'XmlImbParser::refreshBitStreamFromElements'
(0x03000000):Type = 'ComIbmComputeNode'
(0x03000000):Name = 'WorkFlow#FCMComposite_1_10'
(0x03000000):Label = 'WorkFlow.Compute'
(0x03000000):Catalog = 'BIPv600'
(0x03000000):Severity = 3
(0x03000000):Number = 5010
(0x03000000):Text = 'XML Writing Errors have occurred'
(0x01000000):ParserException = (
(0x03000000):File = '/build/S600_P/src/MTI/MTIforBroker/GenXmlParser2/XmlImbParser.cpp'
(0x03000000):Line = 837
(0x03000000):Function = 'XmlImbParser::checkForBodyElement'
(0x03000000):Type = ''
(0x03000000):Name = ''
(0x03000000):Label = ''
(0x03000000):Catalog = 'BIPv600'
(0x03000000):Severity = 3
(0x03000000):Number = 5005
(0x03000000):Text = 'No valid body of the document could be found.'
)
)
)
)
) |
The esql now reads as you said:
Code: |
SET OutputRoot.XML = InputRoot.XML.Message.Attachment;
SET OutputRoot.BLOB.BLOB = CAST(ASBITSTREAM(OutputRoot.XML OPTIONS RootBitStream) AS BLOB CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
SET OutputRoot.XML = NULL;
CREATE PREVIOUSSIBLING OF OutputRoot.BLOB DOMAIN 'XML';
SET OutputRoot.XML.Message."From" = 'test@test.com';
SET OutputRoot.XML.Message."To" = 'test@test.com';
SET OutputRoot.XML.Message.Subject = 'This is the subject';
SET OutputRoot.XML.Message.Body = 'Can you see the attachment?';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)ContentType = 'text/xml';
SET OutputRoot.XML.Message.EncodingBase64.(XML.Attribute)Name = 'attachment.xml'; |
It seems to be a problem when setting the BLOB data with the attachment text, but not entirely sure what. |
|
Back to top |
|
 |
sunny_30 |
Posted: Mon Mar 05, 2007 5:17 am Post subject: |
|
|
 Master
Joined: 03 Oct 2005 Posts: 258
|
Replace the line -
Quote: |
SET OutputRoot.XML = InputRoot.XML.Message.Attachment; |
with
Quote: |
SET OutputRoot.XML.Attachment = InputRoot.XML.Message.Attachment; |
let the rest of the code remain the same.
You will get whatever data you are sending in the attachment tag of the Input XML as an attachment file attachment.xml |
|
Back to top |
|
 |
kayhansefat |
Posted: Mon Mar 05, 2007 6:24 am Post subject: |
|
|
Acolyte
Joined: 18 Oct 2006 Posts: 65
|
Ah brilliant, I can now get the attachment. I think it was also due to the incorrect .lil file being put into the install directory. I get the xml document with the data:
Code: |
<Attachment>Can you see this?</Attachment> |
Which is one step there. My next problem is that the attachment needs to be an xml document, as well as it being named .xml. Therefore the data needs to start like:
Code: |
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE ReportMsg SYSTEM "ReportMsg03.dtd">
<ReportMsg MsgStatus="Live" MsgUrgency="Normal">
<MsgId>Test</MsgId>
<MsgIssueDate>200107252054</MsgIssueDate>
<MsgSender>0080130000101600001</MsgSender>
</ReportMsg> |
The problem here is that I need to exclude the <Attachment></Attachment> part of the data and it will also messup on the:
Code: |
<?xml version="1.0" encoding="ISO-8859-1"?> |
as it is not properly ended with a /.
Any ideas how to include this? |
|
Back to top |
|
 |
|