cancel
Showing results for 
Search instead for 
Did you mean: 

File to Mail Scenario : File Content in the Mail Body

Former Member
0 Kudos

Hello Experts,

We are configuring File to Mail scenario in PO 7.31 single stack. We are using Mail Packaging for this.

Requirement:

When the file is being sent to mail, we need to send whole content of the file in the mail body (AS-IS). Before the file content, we need to add two mail body headers as:

“THIS IS AN SYSTEM GENERATED MAIL. PLEASE DO NOT REPLY”

“The records listed below are the rejected files”


Approach:

We have done the occurrence of the content field in Mail Package as “0...Unbound” use the below UDF:

Output of UDF is coming:

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

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

<Subject>Rejected Invoices - 824</Subject>

   <From>test@xyz.com</From>

   <To> test@xyz.com </To>

  <Content_Type>text/plain;charset=&quot;iso-8859-1</Content_Type>

<Content>This is a system generate message, Please do not reply</Content>

<Content>The records listed below are the rejected invoices :</Content>

   <Content>

</Content>

<Content>ABC</Content>

<Content>123</Content>

<Content>XYZ</Content>

</ns0:Mail>

Issue:

With the above approach, we are getting mail adapter error:

We think this error might be occurring due to multiple occurrence of content field.


We found many blog on SDN. But, all are for file as an attachment and none we found related to our requirement. We also tried achieving this through a by-pass scenario, but we are quite not sure how to add the two message header as mentioned in the requirement.

We don't want to achieve this by Module,Java or XSLT mapping as of now. We would like to achieve this by Graphical Mapping as of now.

If anyone has any idea on the above issue, kindly help us with your valuable inputs.

Referred Blog:

http://scn.sap.com/thread/3375281

Regards,

Vivek

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Vivek,

The approach changing the occurrence from 0...Unbound is wrong. You should not change the standard occurrence.

And use the below code in your UDF:

int length =0;

String result=" ";

result= result+"\n"+ "THIS IS A SYSTEM GENERATED MESSAGE. PLEASE DO NOT REPLY";

result= result+"\n"+"THE RECORD LISTED BELOW ARE REJECTED INVOICES";

for (int i =0; i<var1.length;i++)

result+="\n"+var1[i];

res.addValue(result);

This should work. I have used in my assignment.

Regards,

Nitin Rao

Former Member
0 Kudos

Hi Nitin,

Thanks for your inputs. It works!!

Answers (3)

Answers (3)

gagandeep_batra
Active Contributor
0 Kudos

Hi Vivek,

Did You check this in mapping

I think there is problem with your standard mail structure.

Also check blow blog that may help you:

http://www.saptechnical.com/Tutorials/XI/IDoctoMail/demo.htm

http://www.riyaz.net/sap/xipi-sending-emails-using-xi-mail-adapter/83/

Regards

GB

Former Member
0 Kudos

Hi Krupa,

Still same error .

Transmitting the message to endpoint <local> using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.sdk.xi.srt.BubbleException: Failed to call the endpoint  [null "null"]; nested exception caused by: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {}Content at state

Former Member
0 Kudos

Hi Vivek,

In receiver Mail communication channel, select message protocol as "XIPAYLOAD"

Check "Configure user Authentication", select Authentication method "Plain"

In Mail Attributes, check "Use Mail Package"

Initially to check SMTP service availability, uncheck "Use Mail Package" and provide fixed recipient and see whether Emails are getting passed to respective inbox or not. If SMTP services are ok, then check "Use Mail Package" and see the result.

Regards,

Krupa

Former Member
0 Kudos

Hi Vivek,

Try below UDF and check the output

{

String result = "This is system generate message, Please do not reply" +"\n" +"The records listed below are the rejected invoices:";

for(int i=0;i<var1.length;i++)

result += "\n"+var1[i];

res.addValue(result);

}

Regards,

Krupa.