cancel
Showing results for 
Search instead for 
Did you mean: 

Mail adapter- Attachment file name of scheme ddmm

Former Member
0 Kudos

Hi ,

I am working on File to Mail scenario.

I checked on SDN, but I could not find exact solution.

My requirement is :

I need to mail HTML report file as attachment.

To generate attachment file, I have done XSL mapping.

Attachment file name should be : yyyymmdd.htm

Mail text should be: This is autogenerated mail, please do not reply.

Mail subject: SAP XI report ddmmyyy

Please provide your inputs.

Best Regards,

Divyesh

Accepted Solutions (0)

Answers (3)

Answers (3)

Shabarish_Nair
Active Contributor
0 Kudos

>

> Attachment file name should be : yyyymmdd.htm

> Mail text should be: This is autogenerated mail, please do not reply.

> Mail subject: SAP XI report ddmmyyy

>

> Please provide your inputs.

>

> Best Regards,

> Divyesh

1. Use MessagetransformBean and use the parameter contentdisposition as attachment and contentdescription as <yourfilename>

2 & 3 - Use dynamic configuration and set the values as you want - http://help.sap.com/saphelp_nw04/helpdata/en/f4/0a1640a991c742e10000000a1550b0/content.htm

Former Member
0 Kudos

Hi Shabarish,

Transform.ContentDescription : I need to specify date stamp. it will not be a static name.

How I can achieve this for attachment name and in subject line.

As both should carry "yyyymmdd" and file name should be like 20090331.htm.

Best Regards,

Divyesh

former_member200962
Active Contributor
0 Kudos

Hi,

To name the file as your requirement refer the answer in this thread:

instead of MESSAGE_ID use TIME_SENT (why TIME_SENT??....this is the parameter that you will need to get the date/time the message sent...the list is given in the link: http://help.sap.com/saphelp_nwpi71/helpdata/en/b3/9a2aeb24dc4ab6b1855c99157529e4/content.htm

Mail text should be: This is autogenerated mail, please do not reply.

Not sure how this can be achieved as you have the option of either sending the text as attachment or in the form of mail-body...may be both cannot be achieved simultaneously (i may be wrong here)

regards,

Abhishek.

Shabarish_Nair
Active Contributor
0 Kudos

for a dynamic attachment name i guess a module will be required -

Former Member
0 Kudos

Hi Shabarish,

As you said, writing module will solve problem of attachment file name of scheme: yyyymmdd.htm

But How about setting <Subject> ddmmyyy</Subject>

<Content>This is message from XI</Content>

I have XSL mapping to generate HTML report file, which has to be sent as attachment to mail.

I think , I need to use mail package as well to map Subject and Content fields.

Please advice me on these.

Best Regards,

Divyesh

Shabarish_Nair
Active Contributor
0 Kudos

as i mentioned earlier all those can be set using dynamic configuration

Former Member
0 Kudos

Hi All,

Is it possible to send Mail with text as well attachment file?

I am using XSLT mapping with mail package and in content I am generating attachment file output.

I also need to add message in mail(inline) along with attachment file name.

Best Regards,

Divyesh

Shabarish_Nair
Active Contributor
0 Kudos

http://help.sap.com/saphelp_nw04/helpdata/en/6b/4493404f673028e10000000a1550b0/content.htm

XI payload with mail package:

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

 

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

  <Subject>Subject</Subject>

  <From>emailid</From>

  <To>nameb@id</To>

  <Reply_To />

  <Content_Type>text/plain</Content_Type>

  <Content>

This is the content.

  </Content>

</ns:Mail>

you can indeed set the content

Former Member
0 Kudos

Hi Shabarish,

As I had mentioned , Under <Content>, I am using code of HTML which will go in attachment file.

But how about static message which also should go along in mail message.

Best Regards,

Divyesh

henrique_pinto
Active Contributor
0 Kudos

Hi diveysh,

to have both XML attachment and mail text content, you need to have two payloads (you can create new payloads in the message using the addAttachment() method of the Message class).

For that, you definitelly need an adapter module.

Check the sample module or this wiki for reference: https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/adapterModulePI7.0SetAttachmentName

Regs,

Henrique.

henrique_pinto
Active Contributor
0 Kudos

check out this code:

    ...
    Message msg = (Message)inputModuleData.getPrincipalData();
    ...
    Iterator iterator = msg.getAttachmentIterator();
    Payload xml = (Payload)iterator.next();
    Payload text = msg.createPayload();
    ...
    String message = "the text message"; // you can read this from the input XML (parsing its content)
    String filename = "filename.xml";  // you can also read from ASMA using msg.getMessageProperty() method

    try
    {
      xml.setContentType(
        "application/xml;charset = \"UTF-8\";filename=\"" + filename + "\"");

      text.setContent(message.getBytes("UTF-8"));
      text.setContentType("text/plain;filename=\"text.txt\"");
      msg.addAttachment(text);
    } catch (Exception e)
	//Implement catch...
    }
    ...
    inputModuleData.setPrincipalData(msg);
    ...

Put it in a module.

Include this module in the module process chain before the actual adapter module.

Between it and the adapter module, include the PayloadSwapBean module and replace the xml payload for the text payload, so that the text content will appear in the Mail Body and the .xml file will appear as an attachment.

Regs,

Henrique.

Edit: actually, it seems that you dont need the PayloadSwapBean.

Apparently, the last added attachment is considered as the main payload.

Former Member
0 Kudos

Hi Henrique,

Thanks a lot for your response.

Your answer is very helpful.

I tried your code.

I am getting error in RWB: here I am including audit Log:

2009-04-02 17:39:41 Success MP: Entering module processor

2009-04-02 17:39:41 Success MP: Processing local module localejbs/CreateAttachment

2009-04-02 17:39:41 Success MP: Processing local module localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean

2009-04-02 17:39:41 Success Mail: message entering the adapter

2009-04-02 17:39:41 Success Mail: Receiver adapter entered with qos ExactlyOnceInOrder

2009-04-02 17:39:41 Success Mail: calling the adpter for processing

2009-04-02 17:39:42 Error Mail: call failed; java.io.IOException: Missing mandatory element <sap:Manifest><sap:Payload><sap:Name>

2009-04-02 17:39:42 Success Mail: sending a delivery error ack ...

2009-04-02 17:39:42 Success Mail: sent a delivery error ack

2009-04-02 17:39:42 Error MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: java.io.IOException: Missing mandatory element <sap:Manifest><sap:Payload><sap:Name>

2009-04-02 17:39:42 Error Mail: error occured: com.sap.aii.af.ra.ms.api.RecoverableException: java.io.IOException: Missing mandatory element <sap:Manifest><sap:Payload><sap:Name>

2009-04-02 17:39:42 Error Exception caught by adapter framework: java.io.IOException: Missing mandatory element <sap:Manifest><sap:Payload><sap:Name>

2009-04-02 17:39:42 Error Delivery of the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: java.io.IOException: Missing mandatory element <sap:Manifest><sap:Payload><sap:Name>.

2009-04-02 17:39:42 Success The message status set to WAIT.

Can you please provide me help on this?

Best Regards,

Divyesh

Former Member
0 Kudos

Hi Henrique,

I am getting Null pointer exception after trying your code.

Should I keep Attachments marked?

Can you tell me where I am wrong?

Thanks Again Henrique.

Divyesh

Former Member
0 Kudos

Hello Divyesh,

Were you able to resolve the null-pointer problem?

Thanks,

Tijo

former_member181962
Active Contributor
0 Kudos

Have you gone through the section 3.2.4 of this document?

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9e6c7911-0d01-0010-1aa3-8e1bb155...

Regards,

Ravi Kanth Talagana

DG
Active Contributor
0 Kudos

Hi,

You might be able to use an adapter module, to change the name of the attachment.

/daniel