cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Attachment in Mail Adapter Module

Former Member
0 Kudos

Hi!

My problem: I get an email with an attachment which I process in an adapter module for the mail adapter. With the resulting XML I set a new payload, but the old attachment still exists.

This gets to a problem when I route the message back to the mail adapter, he adds the old attachment to the generated email. Therefore the new email has two attachments: the old one and the new one, which should only be one attachment: only the new one.

How can I remove the old attachment? I found no function which solves this problem.

Best regards,

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

why don't you delete the attachment in the adapter module

before adding the new one?

Regards,

michal

Former Member
0 Kudos

Hi Michal,

that is the point I haven't yet found the way I can delete the old attachment. I searched something like msg.removeAttachment(attachmentName) or msg.removeAllPayload(), but I found nothing which seems to be usefull for this.

I have the feeling, that it is easy to solve, but I can't see the solution

Best regards,

Daniel

MichalKrawczyk
Active Contributor
0 Kudos

hi,

removeAttachment method:

http://help.sap.com/saphelp_nw04/helpdata/en/9a/945e3026760745a751a85499139c7c/content.htm

but I see it only on help.sap.com

I don't see the method in my API (sp17) strange

do you see it ?

Regards,

michal

Former Member
0 Kudos

Hi Michal,

thanks for the link.

When I import aii_proxy_xirt.jar in my NWDS, I can import the MessageSpecifier class. But I can't get an instance of it from the classes which I can access.

The only 'documented' usages of this class I found were codings for java proxies, so I'm not sure we can use this class in an adapter module.

In this cases they get the MessageSpecifier instance from the proxy bean, so maybe we can get it from the EJB, but this doesn't work with an adapter module (or I haven't found out how )

Hmm. It is a simple problem, but it seems difficult to solve

Best regards,

Daniel

Message was edited by: Daniel Himmel

Former Member
0 Kudos

Someone else has an idea how to remove attachments / payloads in an adapter module or maybe in a later stage of message processing (mapping or something else)?

Best regards,

Daniel

Former Member
0 Kudos

I found a "half" solution of the problem: set the content of the attachment to a empty string and change the filename.

But then there is still an empty attachment added to the email which is sent by the mail adapter 😕

No real solution to my problem...

Best regards,

Daniel

Former Member
0 Kudos

Hi Daniel,

I found this in the api documentation ( included in the sample_ra.jar file as demo for building your own adapter ) :

"The Message interface defines several methods for applications to deal with payloads:

-Factory methods to create an empty payload of a specific type.

-Add a payload to the message.

-Get a payload by name or interat over the payloads of a message.

Once a payload is added to the Message, it can not be removed again. To do that, a new Message has to be created and populated with the new payloads."

( and I bumped into this thread while trying to find out if its possible to get access to a messagespecifier interface from an adapter module...)

rgds

Dirk

stefan_grube
Active Contributor
0 Kudos

The class <i>MessageSpecifier</i> is part of the Java proxy framework and not accessible in an adapter module.

The interface com.sap.aii.af.ra.ms.api.Message does not provide any method to remove attachments.

Regards

Stefan

Former Member
0 Kudos

Hi all,

thanks for the information. I "solved" the problem by perfoming a message split. When a message split is performed, new messages are generated out of the source message and all attachments are dropped. Then I route one of the duplicated messages to the adapter which I need and the other message to the fileadapter which writes it to the filesystem to get rid of the unneeded second message.

That is only a workaround, because I get three messages instead of one, but the only solution I see at the moment. Maybe a function to remove existing attachments would be a nice feature for a future support package?

Best regards,

Daniel

Former Member

Answers (0)