cancel
Showing results for 
Search instead for 
Did you mean: 

Mail : Mail Payload doesn't changes to inline (body) still become attachmen

Former Member
0 Kudos

Hi,

I have scenario ABAP Proxy (Main Payload + attachment) ---> Mail (XIPAYLOAD + Mail Package + keep attachment).

=========================== ABAP PROXY OUT ASYN ===========================

attachment_protocol ?= prxy->get_protocol(

if_wsprotocol=>attachments ).

attachment = attachment_protocol->get_attachment_from_binary(

data = attach_xstring

type = if_ai_attachment=>c_mimetype_text_plain

name = 'Outmail' ).

APPEND attachment TO attachments.

attachment_protocol->set_attachments( attachments ).

it-mt_source_proxy-to = 'XXXXXXX'.

it-mt_source_proxy-subject = 'Test email with attachment'.

it-mt_source_proxy-content = 'ccccccccccccccccccccccccccccc'.

CALL METHOD prxy->execute_asynchronous

EXPORTING

output = it.

COMMIT WORK.

=========================================================================

So the result is both payload become attachment. Now the problem is how to change the main payload to become body of email and still keep the attachment become mail attachment.

I have configure PayloadSwapBean and MessageTransformBean in mail adapter receiver as below :

1. localejbs/AF_Modules/PayloadSwapBean swap1

2. localejbs/AF_Modules/MessageTransformBean type2

3. localejbs/AF_Modules/PayloadSwapBean swap2

4. localejbs/AF_Modules/MessageTransformBean type1

swap1 swap.keyName payload-name

swap1 swap.keyValue Outmail

type2 Transform.ContentDescription Outmail

type2 Transform.ContentDisposition attachment;filename="abc.txt"

swap2 swap.keyName payload-name

swap2 swap.keyValue MainDocument

type1 Transform.ContentDescription MainDocument

type1 Transform.ContentDisposition inline

But then the main document content still in attachment cannot change to body eventhough i have put inline in Transform.ContentDisposition.

Please advise, what i am missing in this configuration.

Thank you and Best Regards

Fernand

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

The mail adapter creates MIME type multipart/related, which is not displayed correctly be Microsoft Outlook. There is nothing you can do here.

Regards

Stefan

Answers (3)

Answers (3)

Former Member
0 Kudos

For all, who searches a way for this scenario:

you could write a java mapping and use it after the last other mapping in operation mapping. Use this coding for it:

-----------------------------

import com.sap.aii.mapping.api.*;

import java.util.*;

import java.io.*;

public class MappingPayloadAttachment extends AbstractTransformation{

   

    public void transform(TransformationInput input, TransformationOutput output)

       throws StreamTransformationException {

        getTrace().addInfo("JAVA Mapping Called: MappingPayloadAttachment");

        try{

            InputPayload inpayload = input.getInputPayload();

            InputStream instream = inpayload.getInputStream();

            String instring = this.convertStreamToString(instream);

            InputAttachments inAttachments = input.getInputAttachments();

            OutputPayload outpayload = output.getOutputPayload();

            OutputStream outstream = outpayload.getOutputStream();

            OutputAttachments outAttachments = output.getOutputAttachments();

            //create Output-Payload

            outstream.write(instring.getBytes());

           

            //copy attachments

            if(inAttachments.areAttachmentsAvailable()){

                Collection<String> colAttIds = inAttachments.getAllContentIds(true);

                Iterator<String> attIDsIt = colAttIds.iterator();

                while(attIDsIt.hasNext()){

                    outAttachments.setAttachment(inAttachments.getAttachment(attIDsIt.next()));

                }

            }else{

                getTrace().addInfo("MappingPayloadAttachment Information: no attachment available.\n");

            }

        }catch(Exception e){

            StreamTransformationException ste = new StreamTransformationException(e.toString());

            throw ste;

        }

    }

   

    public String convertStreamToString(InputStream in){

        StringBuffer sb = new StringBuffer();

        try

        {

            InputStreamReader isr = new InputStreamReader(in);

            Reader reader = new BufferedReader(isr);

            int ch;

            while((ch = in.read()) > -1) {

                sb.append((char)ch);}

                reader.close();

            }catch(Exception exception) { }

            return sb.toString();

        }

   

}

-----------------------------

And don't forget to check the cross for "Read Attachments" in Operation Mapping configuration. Now you should be able to config the payload as mail body (inline).

Regards,

Dirk

Former Member
0 Kudos

Hi,

For type2, put following parameters and values and try

Parameter Name Parameter Value

Transform.Class -> com.sap.aii.messaging.adapter.Conversion

Transform.ContentType -> text/plain;charset=utf-8

xml.addHeaderLine -> 0

xml.conversionType -> SimpleXML2Plain

xml.fieldSeparator -> '0x0D''0x0A'

with regards,

Ravi Siddam

Former Member
0 Kudos

Hi

Put Message protocal as " XIALL" u will get the message as attachment as well as Message in the body.

Regards,

Jayasimha Jangam