cancel
Showing results for 
Search instead for 
Did you mean: 

sending Flat file as an Email Attachment

Former Member
0 Kudos

Hi,

I have configured Mail Adapter to send XML Payload as an attachment .

But now i need to send Flat file as an attachment using Mail Adpater . Can any body help me out in this regard

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Please refer the below weblog which explains the same.

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

Thnx

Chirag

Answers (4)

Answers (4)

Former Member
0 Kudos

It was useful

Former Member
0 Kudos

hello everybody,

the thing is to send a .xml file is fine but i want to convert that xml into a flat file before sending it as a attachment. so my question is do i need to use a mail package or i can do it using transformation bean directly, or what else to be done any .xslt transformation. please help me out if any of you has done this before.

Former Member
0 Kudos

Hi ,

Thanks for valuable input . I forgot to mention one more case for Email Adpater .

Scenario is : I need to generate a File ,Pick & send that file as an attachment using email Adapter . Does this use the same concept ( use Additional file parameters in Sender Adpater)

Also , I have a problem in Receiver Determination . The Receiver Determination that is used to generate file (Receiver File Adpater ) . Before i implement this , the same Receiver Detrmination was used for Email Adpater .Since there can be only uinque receiver agreement . I don't know how to configure Receiver Agreement for Email Adapter

aashish_sinha
Active Contributor
0 Kudos

Hi Vinay,

Yes , steps will same as earlier, use the blog i provided you.

*Configuring the Receiver Mail Adapter*

For outgoing mails, you need SMTP or IMAP4 access to your mail server. To access the mail server, enter the following URL:

smtp://YourServer or imap://YourServer/YourInbox

By selecting the Use Mail Package checkbox, you can include additional information to the XI message payload, that is, the mail sender.

If the mail has a plain-text format, you can select the Use Mail Package checkbox to convert the mail message to XML.

Working with Mail Packages

You can dynamically set the sender, receiver, and mail title by using the mail package format. When the mail package format is used, your structure of the payload must adhere to the structure of the mail package.

You can create the mail package structure using the graphical mapping tool. The XSD of the mail package is provided as an attachment in SAP Note 748024.

Creating a Mail Package with XSLT Mapping

If you want to determine the mail receiver dynamically from a payload field, but want the

payload to be sent unchanged, sometimes it is too complicated to use the graphical

mapping tool to create the mapping. The following figure provides an XSLT example that you can use, if your original payload provides the tags sender, receiver, and subject. The XSLT will set these values and copy the whole payload to the Content tag. The original payload will be the mail body.

<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><xsl:value-of select="//subject"/></Subject>

<From><xsl:value-of select="//sender"/></From>

<To><xsl:value-of select="//receiver"/></To>

<Content><xsl:copy-of select="/"/></Content>

</ns:Mail>

</xsl:template>

</xsl:stylesheet>

When you use the MessageTransformBean module in the module processor

configuration of the communication channel, you can directly apply the XSLT mapping to the adapter module.

Enter localejbs/AF_Modules/MessageTransformBean as the first module. Select

the Type Local Enterprise Bean and select a value for Module Key.

You can also use the XSLT file for an interface mapping in the Integration Repository.

Changing the Name and Type of the Payload

By default, the payload of the XI message is sent as an attachment. If you use mail

package, the mail text in the Content tag is sent as a mail body (inline). If you want to change this or influence the name of the attachment, you can do this using the

MessageTransformBean module.

Enter localejbs/AF_Modules/MessageTransformBean as the first module.

Select the Type Local Enterprise Bean and select a value for Module Key.

If you use the Mail Package, then you have to apply the Mime type in the tag

Content_Type:

<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>This is a mail</Content>

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

name="MyFile.xml"</Content_Type>

</ns:Mail>

Exactly how the mail content is displayed at the receiver end depends on the mail client. If the customer has a different mailing system, the mail look may look different at the customer side.

*_Sending a Mail with Attachment (That is what you need)_*

If you want to send a mail with a body and attachment, or with several attachments, the message sender has to provide an XI message with additional attachments. For each additional payload of the XI message, the mail adapter creates an attachment for the mail. To enable this feature, you select the Keep Attachments checkbox when configuring the mail adapter. By default, the payload of the message is also sent as an attachment. If you do not want the payload to be sent as an attachment, set ContentDisposition to inline. If you want to give each attachment a certain name, you can use the swap module. The swap module changes the main payload.

Enter the localejbs/AF_Modules/PayloadSwapBean module as Local

Enterprise Bean between the two modules that change the attachment names.

Select a value for Module Key.

You can find the name of the payload that you want to set as the main payload in the XI message monitor (SXMB_MONI).

Useful SAP Notes

SAP Note 748024: Here you can download the XSD structure of the Mail Package.

SAP Note 794943: Description of the module “PayloadSwapBean”

SAP Note 793922: Description of the module

Hope this will help you.

Regards

Aashish Sinha

PS : reward points if helpful

aashish_sinha
Active Contributor
0 Kudos

Hi,

Follow these steps :

Sequence of Steps:

1)The file that needs to be received as an attachment in the mail, has to be specified in the "Additional File(s)" parameter of the Sender File Adapter

2)The file adapter picks up the file specified in the communication channel together with files specified in additional file parameter.

3)The attachment with main file reaches the server.

4)Then XI Server will send this file as attachment to the receiver Mail Adapter.

5) The mail adapter will send file with the attachment to the Mail Account.

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

Regards

Aashish Sinha

PS : reward points if helpful