cancel
Showing results for 
Search instead for 
Did you mean: 

Mail Adapter & Mail package - pb of content

Former Member
0 Kudos

Hi,

I want to send an email from XI to my mail server (Lotus) by using the Mail Adapter with option "Use mail package".

I have just succeed to send email with only <b>ONE line</b> because of field "content" which has an occurence 0..1.

How is it possible to have several lines?

When I try to duplicate field "content" or to change its occurence (0..Unbounded), then I don't receive an email?

<i>Note: Unfortunatelly, I don't know XSL / XSLT mapping.</i>

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

If you want to have several lines, you have to put EOL within the one "content" tag like this:

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">

<Subject>Hello</Subject>

<From>sender@sender.com</From>

<To>receiver@receiver.com</To>

<Content>row1

row2

row3

row4</Content>

</ns:Mail>

Sorry, I can only give you an XSLT example to do this. Assume your original message payload is:

<root>

<text>row1</text>

<text>row2</text>

<text>row3</text>

<text>row4</text>

</root>

you can use following XSLT file, which you attach directly to the Mail Adapter (like described in another thread):

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="xml" indent="yes" />

<xsl:template match="*">

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">

<Subject>Hello</Subject>

<From>sender@sender.com</From>

<To>receiver@receiver.com</To>

<Content><xsl:apply-templates/></Content>

</ns:Mail>

</xsl:template>

<xsl:template match="text">

<xsl:value-of select="."/>

</xsl:template>

</xsl:stylesheet>

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

Now the same logic with using the graphical mapping tool:

Assume your source structure is:

<root>

<text>row1</text>

<text>row2</text>

<text>row3</text>

<text>row4</text>

</root>

Create a advanced user defined function like this:

public void AddText(String[] a, ResultList result, Container container){

String b = "";
for (int j=0;j<a.length;j++)
  b = b + a[j] + "n";
result.addValue(b);

}

Now you connect

text -> addText -> Content

The rest you fill with constants.

Regards

Stefan

Message was edited by: Stefan Grube

Werner_Magerl
Participant
0 Kudos

Hello Stefan,

your example works fine for a simple message.

But I want to send a complete IDOC by mail to a mailserver.

Can you give me an idea or example how to do this by graphical mapping or XSLT (I'm not fine in XSLT).

What do you mean within this thread, that I can add this XSLT to the mail adapter.

Can you give me some words to search for this thread?

best regards

Werner Magerl