Page tree
Skip to end of metadata
Go to start of metadata
/* This adapter module can be used in sender mail adapter.
   It reads the attachment name from the content type of the MIME header and writes it
   to an adapter specific message attribute (ASMA).
   Put this module after the standard mail adapter module
   If the incoming mail has several parts, then the PayloadSwapBean should be used before this module.
package sample;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
 * @ejbHome <{}>
 * @ejbLocal <{}>
 * @ejbLocalHome <{}>
 * @ejbRemote <{}>
 * @stateless
public class GetAttachmentName implements SessionBean, Module{
	private SessionContext myContext;

	public void ejbRemove() {
	public void ejbActivate() {
	public void ejbPassivate() {
	public void setSessionContext(SessionContext context) {
		myContext = context;
	public void ejbCreate() throws CreateException {

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
                      throws ModuleException{
     try {
         Message msg = (Message) inputModuleData.getPrincipalData();
         TextPayload payload = msg.getDocument();
         String contentType = payload.getContentType();
         // Content Type could be something like
         // text/plain;charset="UTF-8";name="file.txt"
         contentType = contentType.replaceAll("\"","");
         int i = contentType.lastIndexOf("=") + 1;
         String fileName = contentType.substring(i);
                               "FileName", fileName);
    } catch (Exception e) {
         throw new ModuleException(e);

    return inputModuleData;
  • No labels


  1. Unknown User (tgpakxy)


    Can you supply the PI 7.1 version if there are differences. So what you are saying is that the standard mail adapter module goes first in the config, then PayloadSwapBean then the GetAttachment module. I have been using it as SWAP, GETATTACHMENT then the standard Mail adapter.


    Mike Greer

  2. Former Member