cancel
Showing results for 
Search instead for 
Did you mean: 

Mail Adapter Send Mail with Attachment

Former Member
0 Kudos

Hi all,

I'm doing some tests on XI and implemented a little scenario, that send Mails.

So this works fine, but I want to have the content as the content of the mail (no prob) and a attachment with a little more information for the user in a plain text file.

I tried to code it with content-type multipart and all these stuff, but didn't come to a solution.

Some one solved such a scenario already and can help?

I also read some thread on SDN, but no solution. Perhaps its to simple

Thanx

regards

Olli

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Oliver,

We have found the solution for you.

You should configure the mail adapter with 'use the mail adpater' and 'keep attachments'.

Create an XML file conform the XML structure provide by SAP

The mail package should look like this:

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

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

<xi:Mail>

<Subject>Item</Subject>

<From>Mister.A@dummy.nl</From>

<To>Misses.B@dummy.nl</To>

<Content_Type><b>multipart/mixed; boundary="AaBb--984dfgeSSd3532"</b></Content_Type>

<Content_Disposition>attachment</Content_Disposition>

<Content>

<b>AaBb984dfgeSSd3532</b>

Content-Type: text/plain

Hello, this is sample data.

<b>AaBb984dfgeSSd3532</b>

<b>Content-Type:</b> text/plain;name="CSV_data.csv"

Order number;Item number;description<xsl:text>&#xD;&#xA;</xsl:text>

<xsl:for-each select="Article_line">

<xsl:value-of select="Ord_nmbr"/>;<xsl:value-of select="Item_nmbr"/>;<xsl:value-of select="Description<xsl:text>&#xD;&#xA;</xsl:text></xsl:for-each>

<b>AaBb984dfgeSSd3532</b>

<b>Content-Type:</b> text/plain;name="TXT_data.txt"

Order number;Item number;description<xsl:text>&#xD;&#xA;</xsl:text>

<xsl:for-each select="Article_line">

<xsl:value-of select="Ord_nmbr"/>;<xsl:value-of select="Item_nmbr"/>;<xsl:value-of select="Description<xsl:text>&#xD;&#xA;</xsl:text></xsl:for-each>

<b>AaBb984dfgeSSd3532</b>

.

</Content>

</xi:Mail>

</ns:MT_Mail_Sent>

In the above example you should have some content and 2 attachments (1 csv file and 1 txt file).

After each break (AaBb984dfgeSSd3532) specify again the 'Content-Type'.

Good luck

Regards

Ron

Former Member
0 Kudos

Hi,

We tried to use the solution you have given above. When we tried to use it, we are getting mails but it does not contain body and attachments. Please let me know if we are doing anything wrong. FYI. we are checking the incoming mails in outlook express.

Thanks,

Yaseen

stefan_grube
Active Contributor
0 Kudos

Hi Yaseen,

When you want to send a message payload as described, you have to set in the mail receiver channel the parameter <i>Content Encoding</i> to <i>None</i> and uncheck <i>Keep Attachments</i>.

The last boundary <b>AaBb984dfgeSSd3532</b> should be omitted, as the mail adapter sets that border itself (tested with SP16)

Regards

Stefan

0 Kudos

Hi Stefan,

Iam tying to setup the same scenario. I populated the Content filed as described by Ron.

Here is the code used for populating the Content field.

<Content>

AaBb984dfgeSSd3532

Content-Type: text/plain

Hello, this is sample data.

AaBb984dfgeSSd3532

Content-Type: text/plain;name="CSV_data.csv"

<xsl:for-each select="ns0:EmailRequest_MT/row">

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

xsl:text>&#xD;&#xA;</xsl:text>

</xsl:for-each>

AaBb984dfgeSSd3532

Content-Type: text/plain;name="TXT_data.txt"

<xsl:for-each select="ns0:EmailRequest_MT/row">

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

<xsl:text>&#xD;&#xA;</xsl:text>

</xsl:for-each>

</Content>

The problem is that iam not getting any csv or txt attachment files. Iam just getting an email with the following content in the email

<i>AaBb984dfgeSSd3532

Content-Type: text/plain

Hello, this is sample data.

AaBb984dfgeSSd3532

Content-Type: text/plain;name="CSV_data.csv"

Content_Disposition:attachment;"CSV_data.csv"

This is filed 1

This is filed 2

AaBb984dfgeSSd3532

Content-Type: text/plain;name="TXT_data.txt"

This is filed 1

This is filed 2</i>

FYI: In receiver email adapter Content Encoding is set to None and Keep Attachments tab is unchecked.

Can you please help.

Thanks

Pradeep

stefan_grube
Active Contributor
0 Kudos

Is the Contet_Type filled correct?:

multipart/mixed; boundary="--AaBb--984dfgeSSd3532"

Regards

Stefan

Message was edited by:

Stefan Grube

stefan_grube
Active Contributor
0 Kudos

See also this blog which I have created inspired by this thread:

/people/stefan.grube/blog/2007/04/17/xi-mail-adapter-an-approach-for-sending-emails-with-attachment-with-help-of-java-mapping

Former Member
0 Kudos

Hi,

Refer the below weblogs and help:

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken]

http://help.sap.com/saphelp_nw04/helpdata/en/3c/b4a6490a08cd41a8c91759c3d2f401/content.htm

/people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure

Thanks and Regards,

Chirag Gohil

0 Kudos

Stefan,

Content_Type is populated as

<i><Content_Type>multipart/mixed; boundary="AaBb984dfgeSSd3532"</Content_Type></i>

I dont see any difference between your JAVA Program and the above code. Content filed is getting populated in the correct format. Iam not sure whats going wrong here.

Do i have to do anything in the Modules tab of the Receiver Email Adapter for this scenario to work in the intended way??