| Author | Message | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 2:09 am    Post subject: Email with PDF Attachment |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| Hi Champs, 
 I have requirement to send the mails with the attachment using Email Output node.
 
 I am successfully able to send the txt,html and other attachment but facing n using while sending the pdf or image file.
 
 I am getting an xml message having one element contain 64 encoded data ..i have to send this data in an pdf attachment.
 
 I am simply converting this encoded data to blob and sending to Email Output node but while opening the attachment it show invaid or corrupted data error.
 
 
 SET attachment_Content     = CAST(InputRoot.XMLNSC.ns:EmailMessage.ns:Content.ns:Attachment.ns:Content AS BLOB CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);
 
 SET OutputLocalEnvironment.Destination.Email.Attachment.Content   			 =  attachment_ContentBlob;
 i have also set the content encoding to base64 and content type to application/octet-stream.
 
 Please provide any solution if anyone have.
 Thanks
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | smdavies99 | 
			  
				|  Posted: Thu Jan 08, 2015 2:16 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 10 Feb 2003Posts: 6076
 Location: Somewhere over the Rainbow this side of Never-never land.
 
 | 
			  
				| Have you searched this forum for similar posts? 
 something like
 
 
 Or
 
 _________________
 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 |  | 
		
		  |  | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 2:28 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| I had read the forum and followed the same steps as mentioned but didnot got the correct attachment |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Thu Jan 08, 2015 5:12 am    Post subject: Re: Email with PDF Attachment |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| new_to_wmb8 wrote: |  
	| i have also set the content encoding to base64 and content type to application/octet-stream. |  
 Why that? Why not application/pdf?
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 6:19 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| I have tried with that one too but no result |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nelson | 
			  
				|  Posted: Thu Jan 08, 2015 6:36 am    Post subject: |   |  | 
		
		  |  Partisan
 
 
 Joined: 02 Oct 2012Posts: 313
 
 
 | 
			  
				| Not sure if this is the best way, but worked for me: 
 I receive the data in a
 
 
 
   
	| Code: |  
	| <xsd:element name="data" type="xsd:base64Binary"/> |  
 Then cast this content to BLOB:
 
 
 
   
	| Code: |  
	| CAST(InputRoot.XMLNSC.ns:MyTag.ns:data AS BLOB CCSID InputRoot.MQMD.CodedCharSetId); |  
 Finally use this BLOB in a JCN:
 
 
 
   
	| Code: |  
	| byte[] Content = (byte[])MyMbElement.getValue(); attachment.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Content", Content);
 |  
 Maybe you don´t want to split the logic between a compute node and a JCN, so...
 
 Hope this helps
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nelson | 
			  
				|  Posted: Thu Jan 08, 2015 6:42 am    Post subject: |   |  | 
		
		  |  Partisan
 
 
 Joined: 02 Oct 2012Posts: 313
 
 
 | 
			  
				| Forgot to mention: 
 
 
   
	| Quote: |  
	| ContentType = 'application/octet-stream'; ContentEncoding = 'base64';
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 7:07 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| Hi, 
 I am doing the same thing in esql.
 
 
 have decoded the incoming data and set the application/octet-stream and 64Bit but getting the error while try to open the pdf
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nelson | 
			  
				|  Posted: Thu Jan 08, 2015 7:57 am    Post subject: |   |  | 
		
		  |  Partisan
 
 
 Joined: 02 Oct 2012Posts: 313
 
 
 | 
			  
				| Are you sure the incoming data is correct? I remember having an issue with the base64 generated data. I'd check the base64 source data... |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Thu Jan 08, 2015 7:58 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| Did you save the attachment from the sent email, and open it with a text editor? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 8:28 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| Hi, 
 Finally its working.
 
 Thanks to all...
  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | nelson | 
			  
				|  Posted: Thu Jan 08, 2015 8:33 am    Post subject: |   |  | 
		
		  |  Partisan
 
 
 Joined: 02 Oct 2012Posts: 313
 
 
 | 
			  
				| Hi, please share the solution  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | new_to_wmb8 | 
			  
				|  Posted: Thu Jan 08, 2015 9:24 am    Post subject: |   |  | 
		
		  |  Centurion
 
 
 Joined: 28 May 2013Posts: 127
 Location: Hyderabad, India
 
 | 
			  
				| Hi, 
 In my scenario instead to go with JCN, i call the java procedure and decode the incoming encoded data into blob and pass that blob message in the content of the attachment
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Thu Jan 08, 2015 9:33 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| So you didn't use the BASE64DECODE esql function? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |