Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

sending file(from the application server) as an attachment in mail in backg

Former Member
0 Kudos

hi all,

I am having one problem and it goes like this:

i am having one XML file in the application server and i want to send this XML file as an attachment via email in back ground,

can any one help me in this???

<REMOVED BY MODERATOR>

Regards,

Sudeep

Edited by: Alvaro Tejada Galindo on Jan 29, 2008 11:40 AM

2 REPLIES 2

Former Member
0 Kudos

hi

good

*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

thanks

mrutyun^

0 Kudos

hi mrutyunjaya,

I have no idea about XI, i am using simple call transformation to convert the abap code to xml and storing the file to application server, without using xi can i send the file from application server as an attachment via mail,