on 04-01-2009 8:17 AM
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
>
> 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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
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.
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.
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
Have you gone through the section 3.2.4 of this document?
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You might be able to use an adapter module, to change the name of the attachment.
/daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.