cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver Mail Adapter - Body and Attachment

Former Member
0 Kudos

Hello All,

Based on the document How to Use the Mail Adapter of the XI 3.0 J2EE Adapter Engine section 3.2.4 says that the payload of the message is sent as the body and an attachment when the Keep Attachments checkbox is configured. By default, the payload of the message is also sent as an attachment.

In testing this feature - if it is checked I get the attachment - if it is not checked I get the payload in the body of the email. I do not get both.

I am using an xslt mapping.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:ns0="urn:sap-com:document:sap:rfc:functions" xmlns:ns="http://sap.com/xi/XI/Mail/30">
	<xsl:output method="xml" encoding="utf-8" indent="no" omit-xml-declaration="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates select="ORDERS02"/>
	</xsl:template>
	<xsl:template match="ORDERS02">
		<ns:Mail>
			<Subject>
				<xsl:text>Sample Purchase Order: </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
			</Subject>
			<From>
				<xsl:text>mail@Com</xsl:text>
			</From>
			<To>
				<xsl:text>mail@com</xsl:text>
			</To>
			<Content_Type>text/plain; charset="ISO-8859-1"</Content_Type>
			<Content_Disposition>attachment; filename="order.dc"</Content_Disposition>
			<Content>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>A </xsl:text>
				<xsl:text>ORD 238            </xsl:text>
								<xsl:text>
</xsl:text>
				<xsl:apply-templates select="IDOC/E1EDP01"/>
				<xsl:text> </xsl:text>
			</Content>
		</ns:Mail>
	</xsl:template>
	<xsl:template match="IDOC/E1EDP01">
		<xsl:value-of select="concat(' ',/ORDERS02/IDOC/E1EDK01/BELNR)"/>
		<xsl:text>Z</xsl:text>
		<xsl:value-of select="substring(concat(E1EDP19[QUALF=002]/IDTNR,'       '),1,7)"/>
		<xsl:value-of select="format-number(number(MENGE),'00000')"/>
		<xsl:text>                </xsl:text>
		<xsl:text>
</xsl:text>
	</xsl:template>
</xsl:stylesheet>

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

How does the output look like? What is missing?

Former Member
0 Kudos

Hello Stefan,

Thank you so much to taking the time to review my problem.

The output looks like this

[code]

<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30" xmlns:ns0="urn:sap-com:document:sap:rfc:functions"><Subject>Purchase Order: </Subject><From>mail.com</From><To>mail.com</To><Content_Type>multipart/mixed; boundary="b1"</Content_Type><Content>--b12

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

My Order

--b1

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

Content-Disposition: attachment; filename="order.dc"

4501270481A ORD 238

4501270481BThe Wolf Organization

4501270481CPO Box 2044

DYork, PA 17404-2044

4501270481E

4501270481F

4501270481G

Z

Z

Z

Z

Z

Z

Z

Z

Z

</Content>b1</ns:Mail>




And the errror displayed in the RWB - Message Monitoring shows a status of waiting and this error:


I am only using the module reference to mail in my communication channel.

The following error occurred while executing the process:

java.lang.IllegalArgumentException: can't parse argument number http://sap.com/xi/XI/Mail/30

Display Stack Trace

Stack trace for the above error message is:

java.lang.IllegalArgumentException: can't parse argument number http://sap.com/xi/XI/Mail/30

at java.text.MessageFormat.makeFormat(MessageFormat.java:1323)

at java.text.MessageFormat.applyPattern(MessageFormat.java:447)

at java.text.MessageFormat.(MessageFormat.java:347)

at java.text.MessageFormat.format(MessageFormat.java:800)

at jsp_auditlog1160053386093._jspService(jsp_auditlog1160053386093.java:274)

at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)

at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)

at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:316)

at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:372)

at com.sapportals.htmlb.page.PageProcessorServlet.handleRequest(PageProcessorServlet.java:68)

at com.sapportals.htmlb.page.PageProcessorServlet.doGet(PageProcessorServlet.java:29)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)

at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)

at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)

at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)

at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)

at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)

at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)

at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)

at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)

at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)

at java.security.AccessController.doPrivileged(Native Method)

at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)

at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

stefan_grube
Active Contributor
0 Kudos

I think the issue is the namespace declaration. The mail package parser is not a real XML parser, just a stream parser and additional namespace declarations may disturb.

Try to put the namespace declaration directly to the output text and remove them from XSLT header like this:

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

...

You could also try: indent="yes" in xsl:output, as this might prevent the newlines.

Regards

Stefan

Former Member
0 Kudos

Thank you so much for your patience. The mapping works if I do not use the extra content_type tags. Do I need to include the Mime-Version: 1.0....also, notice the


  <Content_Type>multipart/mixed; boundary="b1"</Content_Type> 

Versus


<Content>--b12 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit My Order --b1 

Your example shows use of Content-Type - and the XSLT sample shows <Content_Type> Do you know what the correct format is to use?.

I changed my xsl per your instructions.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
	<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates select="ORDERS02"/>
	</xsl:template>
	<xsl:template match="ORDERS02">
		<ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
			<Subject>
				<xsl:text>Purchase Order: </xsl:text>
			</Subject>
			<From>
				<xsl:text>mail@com</xsl:text>
			</From>
			<To>
				<xsl:text>mail@com</xsl:text>
			</To>
			<Content_Type>
				<xsl:text>multipart/mixed; boundary="b1"</xsl:text>
			</Content_Type>
			<Content><xsl:text>--b12
</xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>Content-Type: text/plain; charset=us-ascii </xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>Content-Transfer-Encoding: 7bit </xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>My Order</xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>--b1</xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>Content-Type: text/plain; charset=us-ascii</xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>Content-Transfer-Encoding: 7bit</xsl:text>
			<xsl:text>
</xsl:text>
			<xsl:text>Content-Disposition: attachment; filename="order.dc"</xsl:text>
			<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>A </xsl:text>
				<xsl:text>ORD 238            </xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>B</xsl:text>
				<xsl:text>The Wolf Organization        </xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>C</xsl:text>
				<xsl:text>PO Box 2044                  </xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:text>D</xsl:text>
				<xsl:text>York, PA  17404-2044         </xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>E</xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>F</xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:text> </xsl:text>
				<xsl:value-of select="IDOC/E1EDK01/BELNR"/>
				<xsl:text>G</xsl:text>
				<xsl:text>
</xsl:text>
				<xsl:apply-templates select="IDOC/E1EDP01"/>
				<xsl:text> </xsl:text>
			</Content>
			<xsl:text>--b1--</xsl:text>
		</ns:Mail>
	</xsl:template>
	<xsl:template match="IDOC/E1EDP01">
		<xsl:text>Z</xsl:text>
		<xsl:text>                </xsl:text>
		<xsl:text>
</xsl:text>
	</xsl:template>
</xsl:stylesheet>

Now my results look like this:


- <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
  <Subject>Purchase Order:</Subject> 
  <From>mail@com</From> 
  <To>mail@com</To> 
  <Content_Type>multipart/mixed; boundary="b1"</Content_Type> 
  <Content>--b12 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit My Order --b1 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="order.dc" 4500000185A ORD 238 4500000185BThe Wolf Organization 4500000185CPO Box 2044 DYork, PA 17404-2044 4500000185E 4500000185F 4500000185G Z Z</Content> 
  --b1-- 
  </ns:Mail>

And the error is still:


Following error occurred while executing the application:

  java.lang.IllegalArgumentException: can't parse argument number http://sap.com/xi/XI/Mail/30 

Display Stack Trace 

Stack trace for the above error message is:


java.lang.IllegalArgumentException: can't parse argument number http://sap.com/xi/XI/Mail/30
	at java.text.MessageFormat.makeFormat(MessageFormat.java:1323)
	at java.text.MessageFormat.applyPattern(MessageFormat.java:447)
	at java.text.MessageFormat.(MessageFormat.java:347)
	at java.text.MessageFormat.format(MessageFormat.java:800)
	at jsp_auditlog1160053386093._jspService(jsp_auditlog1160053386093.java:274)
	at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
	at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
	at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:316)
	at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:372)
	at com.sapportals.htmlb.page.PageProcessorServlet.handleRequest(PageProcessorServlet.java:68)
	at com.sapportals.htmlb.page.PageProcessorServlet.doGet(PageProcessorServlet.java:29)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
	at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
	at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
	at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

stefan_grube
Active Contributor
0 Kudos

That is wrong:

			</Content>
			<xsl:text>--b1--</xsl:text>
		</ns:Mail>

There is untagged content, which is not allowed.

Change this:

			
<xsl:text>--b1--</xsl:text>
</Content>
</ns:Mail>

Former Member
0 Kudos

Thanks for everybody's help. Stefan I changed my code - but am still not getting the results needed.... I am confused when to use the tags for


<Content_Type>multipart/mixed;boundary="=__Part527B4CED.0__="</Content_Type>

or when to use the text

<xsl:text> Content-Type: text/plain; charset=us-ascii<xsl:text>

What I have now gives me a payload that looks like this...the message is sent but there are no attachements or content.


- <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
  <Subject>Purchase Order:</Subject> 
  <From>mail</From> 
  <To>mail</To> 
  <Content_Type>multipart/mixed;boundary="=__Part527B4CED.0__="</Content_Type> 
  <Content_Disposition>attachment; filename="p1.txt"</Content_Disposition> 
- <Content>
  --=__Part527B4CED.0__= 
  <Content_Type>text/plain; charset="ISO-8859-1"</Content_Type> 
  <Content_Disposition>inline</Content_Disposition> 
  My Order --=__Part527B4CED.0__= 
  <Context_Type>text/plain; charset="ISO-8859-1"</Context_Type> 
  <Content_Disposition>attachment; filename="order.dc"</Content_Disposition> 
  4500000185A ORD 238 4500000185BThe Wolf Organization 4500000185CPO Box 2044 DYork, PA 17404-2044 4500000185E 4500000185F 4500000185G Z Z --=__Part527B4CED.0__=-- 
  </Content>
  </ns:Mail>

stefan_grube
Active Contributor
0 Kudos

Remove any additional Content_type or Content_dispostion tag after content.

This must be constant parameters:

Instead of

> - <Content>

> --=__Part527B4CED.0__=

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

> <Content_Disposition>inline</Content_Disposition>

> My Order --=__Part527B4CED.0__=

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

> <Content_Disposition>attachment; filename="order.dc"</Content_Disposition>

> 4500000185A ORD 238 4500000185BThe Wolf Organization 4500000185CPO Box 2044 DYork, PA 17404-2044 4500000185E 4500000185F 4500000185G Z Z

> --=__Part527B4CED.0__=

> </Content>

it must be

> - <Content>

> --=__Part527B4CED.0__=

> Content-Type: text/plain; charset="ISO-8859-1"

> Content-Disposition: inline

> My Order

>

> --=__Part527B4CED.0__=

> Context-Type: text/plain; charset="ISO-8859-1"

> Content-Disposition: attachment; filename="order.dc"

>

> 4500000185A ORD 238 4500000185BThe Wolf Organization 4500000185CPO Box 2044 DYork, PA 17404-2044 4500000185E 4500000185F 4500000185G Z Z

> --=__Part527B4CED.0__=

> </Content>

Former Member
0 Kudos

Refer to link below

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c...

and try with PayloadSwapBean

Gaurav Jain

Reward Points if answer is helpful