ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Email Attachment Encoding Problem.

Post new topic  Reply to topic
 Email Attachment Encoding Problem. « View previous topic :: View next topic » 
Author Message
Agua
PostPosted: Mon Dec 17, 2012 6:46 am    Post subject: Email Attachment Encoding Problem. Reply with quote

Newbie

Joined: 17 Dec 2012
Posts: 2

Intro:

Im having issues refered to attachment encoding. I got an flow that send an email through an emailoutput node, it uses an xml to dinamically set the values. The flow is working perfectly and can send mails, but attachments don't work properly.

Problem description:

If i send an encoded .txt file as an attachement, it works just fine and sends the mail and the .txt file. However, if I send any other file, the mail is sent, with the file correctly attached, but the file is corrupted, so you can't open it properly.


This is the code i am using:

Quote:
IF EXISTS(InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment[]) THEN
SET OutputLocalEnvironment.Destination.Email.Attachment.ContentType = InputRoot.XMLNSC.EmailInput.EmailDetails.ContentType;
SET OutputLocalEnvironment.Destination.Email.Attachment.Content = CAST(BASE64DECODE(CAST(InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment AS CHARACTER))AS BLOB CCSID 1208);
SET OutputLocalEnvironment.Destination.Email.Attachment.ContentName = InputRoot.XMLNSC.EmailInput.EmailDetails.AttachmentName;
END IF;


And this are the lines of the xml:

Quote:
<Attachment> Base64 encoded msword .doc document</Attachment>
<ContentType>application/msword</ContentType>
<AttachmentName>Message.doc</AttachmentName>




I really hope you can help me, i'll be bold very soon if i keep scratching my head like this... =P




PD: Obviosly, im sending a real msword .doc base64 encoded document, not the lines, i just though putting the entire encoded message would be a waste of space.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Dec 17, 2012 7:13 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Why would you want to decode the MSWord document.
Obviously it is carried as a BLOB base 64 encoded which should be just a passthrough.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Dec 17, 2012 7:33 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I agree with fjb_saper. But if you come up with a good reason for decoding this base64 field, then I have some questions of my own:
Code:
CAST(BASE64DECODE(CAST(InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment AS CHARACTER))AS BLOB CCSID 1208);

- What is the data type of InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment ?
- What data type does BASE64DECODE return ?

When you have answered those questions, you should be able to make that line of code a lot simpler.
Back to top
View user's profile Send private message
Agua
PostPosted: Mon Dec 17, 2012 8:05 am    Post subject: Reply with quote

Newbie

Joined: 17 Dec 2012
Posts: 2

First of all, thanks for your answer.

I sent the attachment by using this line(without base64decode):

SET OutputLocalEnvironment.Destination.Email.Attachment.Content = CAST(CAST(InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment AS CHARACTER)AS BLOB CCSID 1208);

I got the same results, a corrupted message.doc. The file im sending its an encoded .doc file. (I encoded the fiel in base64 using a script).

Quote:
- What is the data type of InputRoot.XMLNSC.EmailInput.EmailDetails.Attachment ?
- What data type does BASE64DECODE return ?


The data is a .doc file i encoded to base64.
The data type returned its a BLOB (hexadecimal), I cast it as blob using ccsid1208 to make sure its using utf8.


Any other ideas??
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 18, 2012 3:25 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Agua wrote:

The data is a .doc file i encoded to base64.
The data type returned its a BLOB (hexadecimal), I cast it as blob using ccsid1208 to make sure its using utf8.


Any other ideas??

Never heard of anything more brain dead.
a) a byte is a byte regardless of CCSID.
b) base64 encoding should allow to have an encoding that fits the char model.... so use base64 decode....
c) using base64 decode does not give you a character array but a byte array representing the .doc file. Changing the CCSID on it as if it were a char array WILL corrupt the data for sure.

As I said, keep the encoding and use as a pass-through. If you absolutely need to change the encoding change it on the encoded values...

Your problem is: you should never have base64 decoded the attachment!!

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Email Attachment Encoding Problem.
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.