cancel
Showing results for 
Search instead for 
Did you mean: 

how to use set.ContentType in UDF

Former Member
0 Kudos

Can somebody please tell me how to use set.ContentType in UDF?

I have to set the Content-Type of the email attachment in UDF but I am getting this error

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");
result.addValue(attachmentContent);

Thanks,

Iqbal

Accepted Solutions (0)

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi Muhammad,

At first your mistake is the next:

attachmentContent = new String(attachments.getContent()); --This means that                                                                         attachmentContent has a String type

attachmentContent.setContentType("application/xml; charset=utf-8") --String doesn't                                                                                 have a method setContentype!!

Example:

// get the XI message from the environment

Message msg = (Message)

inputModuleData.getPrincipalData();

// create a new payload

TextPayload attachment = msg.createTextPayload();

// provide attributes and content for the new payload

attachment.setName("Attachment");

attachment.setContentType("text/plain");

attachment.setText("Hello World");

// add the new payload as attachment to the message

msg.addAttachment(attachment);

// provide the XI message for returning

inputModuleData.setPrincipalData(msg);

You can read these threads also:

http://scn.sap.com/thread/1946656

http://scn.sap.com/thread/1881560

This problem is the same that is in this other thread open by you http://scn.sap.com/thread/3180179, isn it?

Regards and good luck

Message was edited by: Iñaki Vila