on 05-22-2012 4:37 PM
Hi All,
I have a requirement in which I need to read the email attachment and perform the mapping.
I am able to read the content through JAVA UDF but I am facing problem with the File encoding.
It is showing the Email Attachment Content as "application/octet-stream;name="abc.xml" and I am wondering if anybody know how to convert this Content-type into "text/xml".
I have tried this but it's not working
Content = attachmentContent.setContentType("text/xml");
Is there any way we can set the file encoding to UTF-8 in JAVA UDF or can anybody tell me the how to read the email attachment through UDF or XSLT?
Thanks,
Iqbal
Mail attachment supports MIME type.
Can you try setContentType("application/xml");
or
setContentType("application/xml; charset=utf-8"); and see how that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Baskar,
I am getting this error
Hi Baskar,
I am not using any response object I am just getting the email content and return that as it is but by default it is not using the UTF-8 encoding so I need to set the encoding.
I am using this function
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
attachmentContent = new String(attachments.getContent()); | |
attachmentContent.setContentType("application/xml; charset=utf-8"); |
attachtmentContent is the string object. You cannot do this way... You have to see the below sap help links for how to get outputAttachments from globalContainer object and create Attachment object for contentType and finally set the attachment using outputAttachment.. Refer this link
http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mappingtool/tf7/rt/GlobalContainer.html
http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/OutputAttachments.html
HI Baskar,
Is it possible for you to provide me the code or correct my code?
I am trying this but still getting an error.
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
OutputAttachment outputAttachments = globalContainer.getOutputAttachments();
attachmentContent = new String(attachments.getContent());Attachment attachments = inputAttachments.getAttachment(attachmentID);
OutputAttachment = Outputattachment.setContentType("application/xml; charset=utf-8");
result.addValue(attachmentContent);
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
Attachment inputAttachments = inputAttachments.getAttachment(attachmentID);
OutputAttachment outputAttachments = globalContainer.getOutputAttachments();
Attachment attach = OutputAttachment.create(attachmentID, "application/xml;charset=utf-8", attachments.getContent());
result.addValue(attach.getContent().toString());
Note: The above coding is sample for you to enhance further. I'm currently not at my desk to compile the code.
Hi Baskar,
I am getting this error
any suggestion?
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.