Skip to Content
avatar image
Former Member

File to Mail Receiver with Attachment without mapping

Hi all,

I have a requirement to send forecast files to the customer as email attachment.

The file is available as plain text in an FTP source directory. XI has to pick this up and send this file as email attachment. No content in email body is required. The attachment name in the email should be the same as the filename

Everything is fine but the problem is the filename in the email is always coming as 'Untitled.xml'

Here are the my module parameters for the receiver mail adapter. I have a limitation not to use Message Mapping

Requesting expert advise if anything else is missed. Thanks in advance.

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Dec 22, 2014 at 06:44 AM

    Hi Sudha,

    Did you try with Standard Modules as explained in following:

    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816?QuickLink=index&…

    Regards,

    Azhar

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      This link was very helpful!  I searched many links and none could explain how to rename the attachment in the module tab of receiver email adapter..  Using this documentation I was able to configure the message transformation bean to configure a renaming of the attachment inside the email.

  • avatar image
    Former Member
    Dec 22, 2014 at 11:07 AM

    Hi Sudha,

    Please check the below link :

    Renaming Email Attachment with input File Name Without Module

    Regards,

    Ramesh

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 22, 2014 at 11:45 AM

    Hi Sudha,

    Please checkbelow thread

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

    Thanks,

    Sreenivas

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 22, 2014 at 07:05 PM

    Hi Sudha,

    I think, File to Mail with FileName as attachmentName, is not possible using standard modules. You can try modules in this blog (it is Mail to File with attachmentName as FileName).

    You can use below solution.

    Develop a dummy DT, MT, SI, OM. Use below Java Mapping. Call this OM in interface determination.

    Set "Adapter-Specific Message Attributes" in sender channel.

    package javaapplication1;
    
    
    import java.io.OutputStream;
    
    
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import java.io.InputStream;
    import java.util.Map;
    
    
    public class JavaApplication1 extends AbstractTransformation {
    
    
        @Override
        public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
            try {
                InputStream inputstream = transformationInput.getInputPayload().getInputStream();
                OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
    
    
                //a) Get FileName from DynamicConfiguration.
                Map mapParameters = (Map) transformationInput.getInputHeader().getAll();
                DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
                DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    
    
                String FileName = conf.get(key);
               
                //b) Set attachment Name.
                transformationOutput.getOutputHeader().setContentType("text/plain;charset = \"UTF-8\";" + "name=\"" + FileName + "\"");
    
    
                // c) Just copy Input file content to Output file content
                byte[] b = new byte[inputstream.available()];
                inputstream.read(b);
                outputstream.write(b);
                
            } catch (Exception exception) {
                getTrace().addDebugMessage(exception.getMessage());
                throw new StreamTransformationException(exception.toString());
            }
        }
    }
    
    Add comment
    10|10000 characters needed characters exceeded