Skip to Content
Sep 23, 2013 at 05:44 AM

Adapter Module to Rename Attachement in MAIL Recever Side Issue


Hi Guys,

In one of my requirement, i need to have an email attachment and body as well.

For this used an artcle

I did the same but not getting the attachment with Renamed value.

My Adapter configurations as below:

The below is my module code: and also you see the logs which got from the channel monitoring.

//-------------------------Sree Code2 Start Here------
public static final String VERSION_ID ="$Id://tc/aii/30_REL/src/_adapters/_sample/java/user/module/ $";

static final long serialVersionUID = 7435850550539048633L;

String fileName = null;


public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException


String SIGNATURE = "process(ModuleContext moduleContext, ModuleData inputModuleData)";

Location location = null;

AuditAccess audit = null;

Payload attName =null;

int attnum=0;

try {

location = Location.getLocation(this.getClass().getName());


catch (Exception t)



ModuleException me = new ModuleException("Unable to create trace location", t);
location.throwing(SIGNATURE, me);
throw me;


Object obj = null;

Message msg = null;

MessageKey key = null;

try {

obj = inputModuleData.getPrincipalData();

msg = (Message) obj;

key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());

audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();

audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "EmailAttach: Module called");

fileName = msg.getMessageProperty("", "FileName");

audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"RequestFileName:" + fileName);


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"number of Attachment: " + attnum);

attName = msg.getAttachment("%F");

audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"Name of Attachment after msg.getattchment method: " + attName.getName());


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"Name of Attachment after msg.removeattchment method: " + attName.getName());


if(attName != null)


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"Name of Attachment: " + attName.getName());




audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"Attachment not found" + attName);





audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"Attachment name is successfully changed to : " + attName.getName());


catch(Exception e)


audit.addAuditLogEntry(key, AuditLogStatus.ERROR,attName +": attachmentName is not matching");

ModuleException me = new ModuleException(e);

throw me;


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"No of Attachments Before attachment added: " + msg.countAttachments());


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,"No of Attachments After attachment added: " + msg.countAttachments());

audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS," Before Attachment added to InputModueData.");


audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS," After Attachment added to InputModueData.");


catch (Exception e) {

ModuleException me = new ModuleException(e);

throw me;


return inputModuleData;//sending original payload to call adapter.


//-------------------------Sree Code2 End Here---------

My Sender Channel as below:

Channel Monitoring LOG:

Generated Email as below:

Please sugget me what is wrong in the coding OR in any place in the configuration.