cancel
Showing results for 
Search instead for 
Did you mean: 

Encoding conversion in Mail adapter

Former Member
0 Kudos

Hi,

we have a problem with the Mail adapter...

We try to send an email out of the XI to some service providers. The outgoing data is stored in an XML structure. This structure agrees with the conventions of the Mail Package format, which is used for dynamic Mail generation. The content of this Mail Package structure is a semicolon separated string, which should be attached as a CSV-File to the outgoing email. Up to this everything works fine. We get the email with the attachement out of the system, send it to a SMTP server and transfer it to a previous defined email address.

But when we open the attachement (with Wordpad, Excel,...) all german umlaut have been lost. The problem is, when transfering the Mail Package content into a File, this File is UTF-8 encoded.

Can anyone give us a hint how to convert the encoding of the attached file from UTF-8 to ISO-8859-1 (Latin-1)?

Actual we have set the following parameters on the module page:

Work sequence

1. localejbs/AF_Modules/MessageTransformBean      Local Enterprise Bean      XML2Plain
2. localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean       Local Enterprise Bean      mail

Modulconfiguration

XML2Plain     Transform.ContentDisposition     attachment;filename="ABC.csv"
XML2Plain     Transform.ContentType      text/plain;charset=latin-1
XML2Plain     Transform.ContentDescription      "ABC"

I hope we get some help...

Regards,

Lars

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Hi

We handled the similar requirement in our project.

To convert the target file encoding UTF-8 to ISO-8859-1. For this i have used XSLT mapping, by changing the output encoding as shown in the code.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:a="urn:abc.com:pi:ab:cd:FileToMail:Mail">
<xsl:variable name="vfileName" select="/a:MT_Mail/FileName"/>
                <xsl:output method="text" indent="yes" encoding="iso-8859-1" media-type="TYP"/>

also set the charset value to ISO-8859-1 as shown in the XSLT mapping


                 <xsl:text>----mime-boundary
Content-Type: text/html; charset="ISO-8859-1"
Content-Disposition: inline

In Adapter module, add XMLAnonymizerBean

Link:http://help.sap.com/saphelp_nwpi71/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm

Hope this will resolve your issue.

Regards,

Divya

Edited by: Divya_10 on Jun 14, 2011 10:20 AM

stefan_grube
Active Contributor
0 Kudos

When you use the mail package, you have to provide the content type information in the tag <i>Content_Type</i>.

So you have to add

<Content_Type>text/plain;charset="ISO-8859-1"</Content_Type>

to the XML.

The entry <i>Transform.ContentType</i> from the module configuration is ignored, when you use the Mail Package.

Hope that helps

Stefan

Former Member
0 Kudos

Hi Stefan,

thank you for your answer... I've changed the XML, but there is no change in the encoding of the attachment. It is still UTF-8.

The Payload from our Message, which you can see in the XI Monitoring (Transaction SXMB_MONI), has the following structure:

<?xml version="1.0" encoding="UTF-8" ?> 
<ns0:Mail xmlns:ns0="http://sap.com/xi/XI/Mail/30">
  <Subject>Testmessage</Subject> 
  <From>lars.ottawa@xyz.de</From> 
  <To>lars.ottawa@xyz.DE</To> 
  <Content_Type>text/plain;charset="ISO-8859-1"</Content_Type> 
  <Content>4264673;DE;33334;Bartholomäusweg 26;Gütersloh;Lars;Ottawa;99.9;1;1;;129717</Content> 
</ns0:Mail>

When we try to open the attachment (with an editor) we get the following string...

4264673;DE;33334;Bartholomäusweg 26;Gütersloh;Lars;Ottawa;99.9;1;1;;129717

It seems that the Content Type attribute has no effect. Could that be possible?

Regards,

Lars

stefan_grube
Active Contributor
0 Kudos

Are you sure, the content in your example is UTF-(? What is the source for this? How do you map?

I tested with source ISO-8859-1 and UTF-8, as target as well ISO-8859-1 and UTF-8 and all worked well.

Which SP do you use?

Stefan

Former Member
0 Kudos

We are sure that we get a UTF-8 encoded attachment, because when we open it in an UTF-8-compatible Editor and use the UTF-8 view mode, everything looks fine...

The source of this example is a CRM 4.0 system and we are using graphical mappings (message mappings). The semicolon seperated string is created in this mapping with an advanced user defined function.

On our XI service pack 12 is installed.

Lars

stefan_grube
Active Contributor
0 Kudos

It seems to be a bug.

There will be a patch for SP121314.

The corresponding note 881308 is released now.

Regards

Stefan

Message was edited by: Stefan Grube

former_member189519
Participant
0 Kudos

Hi, we are on SP15Build0 so the fix should be applied

however i got the following results:

fileadapter with iso-8859-1

how can i use the mailadapter with the right encoding?

stefan_grube
Active Contributor
0 Kudos

content deleted

stefan_grube
Active Contributor
0 Kudos

Make sure, that you have put the content type "text" and codepage "iso-8859-1" to the sender channel of the file adapter.

Stefan

former_member189519
Participant
0 Kudos

Hi Stefan, nice to hear again from you (we have seen us at HUGO..)

the file adapter does the job, only the email adapter fails in encoding the message.

The email adapter should do more jobs for me as i receive messages from outlook/notes

1. Swap to the mysterious content

Content-Type=multipart/alternative

2. Transform it

Transform.ContentType=text/plain; charset=utf-8

(error described in )

3. Swap to attachment

Content-Description=MailAttachment-1

4. Transform .csv-attachment with content conversion

Transform.Class=com.sap.aii.messaging.adapter.Conversion

Transform.ContentType=text/xml;charset=iso-8859-1

xml.conversionType=StructPlain2XML

xml.processFieldNames=...

so the encoding for the transformed message should be iso-8859-1 ?!

I doesnt matter if i use "text/plain" or "text/xml".

If i prepare the email i can skip step 1 and 2 but the result is the same.

You meant "codepage"? Is it another attribute i can set?

stefan_grube
Active Contributor
0 Kudos

So you talk about mail to file.

The original post was just the other way around.

See what I have written here:

Regards

Stefan

former_member189519
Participant
0 Kudos

I already did

Transform.ContentType text/

stefan_grube
Active Contributor
0 Kudos

Put the message transfrom bean two times in the module tab.

first: text/plain;charset="ISO-8859-1"

second: text/plain;charset="UTF-8"

former_member189519
Participant
0 Kudos

same result as i enter only utf-8

characters are broken

i cant get any umlaut "äöü" from the mailadapter-messagetransformationbean

stefan_grube
Active Contributor
0 Kudos

Could you send me this email to stefan.sdn@googlemail.com

Stefan

stefan_grube
Active Contributor
0 Kudos

You have to assign the conversion to the second Bean. In the first Bean put only the content type.

former_member189519
Participant
0 Kudos

btw. interesting effect

if i add the messagetransformationbean to the fileadapter, the umlauts are not changed to utf-8 (auditlog shows the successful transformation to utf-8)?

maybe the "Transform.Class=com.sap.aii.messaging.adapter.Conversion" makes problems?

Next i will try with an already converted csv-to-xml attachment

stefan_grube
Active Contributor
0 Kudos

I am a little bit lost.

Can you explain your scenario?

What modules do you use? Where did you place them?

Stefan

former_member189519
Participant
0 Kudos

scenario:

mails with and .csv attachment should be mapped to an rfc-call

i did:

1. sender mail adapter which should convert the attachment using the contentconversion module (from you : https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f02d12a7-0201-0010-5780-8bfc7d12...

So i tried to attach the already converted csv-to-xml to the email and everything works fine.

The problem is the conversion-class! It cant handle umlauts or other county specific encoding.

The content-conversion from the fileadapter works. The module in the email adapter fails.

Can you confirm this?

stefan_grube
Active Contributor
0 Kudos

Have you tried to apply a second entry of MessageTransformBean before the one which does the conversion?

former_member189519
Participant
0 Kudos

yes, check your mailbox, i sent you my module-settings

former_member189519
Participant
0 Kudos