cancel
Showing results for 
Search instead for 
Did you mean: 

Mail Adapter Module Problem!

Former Member
0 Kudos

Hi All

I m facing a problem in implementing a custom mail adapter module.

The scenario is to set the content type based on the file type. eg: if the file being sent is a pdf then content type should be "application/pdf".

I hope the scenario is clear, please feel free to ask for clarifications.

awaiting your replies.

Regards

Kapil

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All

I am able to fetch the file name now and set the content type based on the file name. But I m not able to change the name of attachment of mail. For reference, I m pasting the code here, please suggest how to do the latter part

try {
				 // CS_GETCHADAT START
				 cid  = moduleContext.getChannelID();
				 Channel channel = new Channel(cid);
				 // Example to access a channel configuration parameter in a module: String someParameter = channel.getValueAsString("YourAttributeName");
				 // CS_GETCHADAT END
				 
				fileName = msgg.getMessageProperty("http://sap.com/xi/XI/System/File","FileName");
				Payload attachment = msgg.getAttachment("MainDocument");
				
				
				 
					StringTokenizer st = new StringTokenizer(fileName, ".");
					while(st.hasMoreTokens()){
						extension = st.nextToken();	
					}
					
					
				Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "RenameFile: filename " + fileName);
				Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "RenameFile: extension " + extension);
					

					
					// create new payload


					Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS, "RenameFile: attchmntName " + attachment.getName().toString());
					
					//provide attributes and content for the new payload
					attachment.setName("Attachment :" + fileName);
					
//					msgg.setMessageProperty("http://sap.com/xi/XI/System/File","content-description",fileName);
					attachment.setContentType("application/" + extension );
					
					inputModuleData.setPrincipalData(msgg);

stefan_grube
Active Contributor
0 Kudos

Try this:

attachment.setContentType("application/" + extension + "; name="" + filename + """);

Let me know, if this works.

Stefan

Former Member
0 Kudos

Hi Kapil,

What do u mean by a custom mail adapter module which will handle any type of xtension or r u using the standard module MessageTransformBean module. Nut, the standard module will be able to handle ur case.

Check the following link

<a href="https://websmp109.sap-ag.de/form/sapnet?_SHORTKEY=01200252310000071155&_SCENARIO=01100035870000000202&_OBJECT=011000358700004556712005E">https://websmp109.sap-ag.de/form/sapnet?_SHORTKEY=01200252310000071155&_SCENARIO=01100035870000000202&_OBJECT=011000358700004556712005E</a>

<a href="/people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi:///people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi

Regards,

Akshay

Former Member
0 Kudos

Hi Kapil,

could MessageTransformBean a solution?

You can set the type of your payload using the following modules parameters:

localejbs/AF_Modules/MessageTransformBean | Local Enterprise Bean | transform

transform | Transform.ContentType | XYZ

You need to replace XYZ by the type.

Regards,

Torsten