cancel
Showing results for 
Search instead for 
Did you mean: 

How to send mails to dynamic receivers using XSLT mapping

Former Member
0 Kudos

Hi All,

I have a problem with the mail attributes in xslt mapping. I have a condition on a source field, based on which the "TO" attribute should vary.

For Example : If ROOT/HEADER/XYZ = 001 then receiver should be some abc email id

If ROOT/HEADER/XYZ = 002 then receiver should be

pqr email id.

Can anyone help me out of this

Thanks in advance.

Regards,

Lakshmi.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi...

We have used the concept of CHOOSE element inside TO attribute. but it is not working. I guess we cant apply any elements inside Mail attributes.

Gaurav,

Your solution is correct when we have 2 known values for a variable.

But, In our case, we should get value for TO depending on input file.

For example...If Input file have a value "000" then TO address should be mail id of A. else the TO address should be mail Id of B.

Former Member
0 Kudos

Hi Lars,

Is it possible to write dynamic mail ids in "TO" field. If so how?

Regards,

Lakshmi.

Former Member
0 Kudos

Hi Lakshmi,

you have to create an appropriate mapping for this. As said, the mentioned mail package format will be your message. The message will be analyzed by the mail adapter and after this the TO field will be filled with the correct value you will use. The structure inserted into the content fields will be send in the mail body or, if set in the configuration, as an attachement of the mail (as far as i know (-; )

Example:

Original structure:


<ContentStructure>
  <ValueA>ID1</ValueA>
  <ValueB>XYZ</ValueB>
</ContentStructure>

Extract of an XSLT-Mapping (as an example, you can use the mapping type you prefer):


<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
  <Subject>Subject</Subject>
  <From>namea(at)company.com</From>
  <To>

    <xsl:choose>
      <xsl:when test="ContentStructure/ValueA='ID1'">
        nameb(at)companyb.com
      </xsl:when>
      <xsl:when test="ContentStructure/ValueA='ID2'">
        namec(at)companyc.com
      </xsl:when>
    </xsl:choose>

  </To>
  <Reply_To />
  <Content_Type>text/plain</Content_Type>
  <Content>
    This is the content.
  </Content>
</ns:Mail>

If you try something like this, you will be able to set the TO email address dynamical.

Rregards,

Lars

Former Member
0 Kudos

HI Laxmi

Are you using XSLT only for this requirement

That even you can achieve using the standard mapping IF ELSE.

But if you have to use XSLT only then it is possible. The code given above will help else you can do this way as well

Use

<xsl:variable name="toField1">value for 1st option</xsl:variable>
<xsl:variable name="toField2">value for 2nd options</xsl:variable>

To use the above defined variable field

Use

<xsl:value-of select="toField1"/> or <xsl:value-of select="toField2"/>

as per your need

Here you can define to fields as variables and use as per your choice any where in the XSLT.

Thanks

Gaurav

Former Member
0 Kudos

Hi Lakshmi,

if you use the mail adapter you can use the mail package format (a special XML structure) for your requirement. In the configuration of your mail adapter set the setting of Mail attributes to the following option "Use mail package".

After this you have to use the following XML. This should be the payload of your message...


<?xml version="1.0" encoding="UTF-8"?>

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
  <Subject>Subject</Subject>
  <From>namea(at)company.com</From>
  <To>nameb(at)company.com</To>
  <Reply_To />
  <Content_Type>text/plain</Content_Type>
  <Content>
    This is the content.
  </Content>
</ns:Mail>

Just have look in the SAP Help: Link: [http://help.sap.com/saphelp_nwpi71/helpdata/en/44/8da2597e473ac1e10000000a155369/frameset.htm]

Regards,

Lars