on 11-02-2017 8:32 AM
We have a requirement,We need to get the mail ID from the payload and send it to that particular mail ID. We are using file to Mail scenario and message should be sent as an attachment.
Mail ID is different in each message.
Hi Bharat,
Can you provide more details about the requirement. There are different points we need to consider while handling this scenario. I've worked on couple of similar requirements and I would suggest finalizing the requirement before deciding on the approach.
You mentioned that source file has to be sent as an attachment. Is it an XML/Text attachment?
Do you need mail body & attachment or only attachment? - If you need both body & attachment, there are 2 approaches. One is using mailpackage and other is java mapping. SAP recommends to use java mapping instead of mail package.
If you are not comfortable with java mapping, you can still continue using mail package.
What should be the attachment name? Is it static or dynamic like source file name has to be attachment name etc.?
any other requirements like email subject etc.?
Provide the complete requirement so that I can help you in achieving it.
--Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As the source & attachment is a text file and the mail recipients are in the payload, you need to use content conversion and mapping. Below is the approach I can think of to avoid javamapping & use Mail package.
1. In the File sender channel, do the content conversion and also enable Adapter Specific Message Attributes to read source file name.
2. Create a simple 1:1 message mapping with same structure on both source & target side. Only thing is, while map the target room with a UDF.
3. In the UDF, use dynamic configuration, read the source file name & write it to mail header say "XHeaderName1". Also set the email email recipient. Below is the sample code.
String emailTo = "abc@xyz.com";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey emailToAdd = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail","THeaderTO" );
conf.put(emailToAdd, emailTo);
Also refer below links to set attachment name.
https://archive.sap.com/discussions/thread/3912824
4. In Mail receiver channel,
--Priyanka
Hi Priyanka ,
Thanks for your answer.
I have tried with the above code for setting the email ID dynamically , Im getting below error.
Runtime exception when processing target-field mapping /ns0:MT_Desadv1_ToMail_Target//ns0:MT_Desadv1_ToMail_Target/*Email_TO; root message: Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of a null object loaded from a local variable at slot 4] in class com.sap.xi.tf._MM_Desadv1_ToMail_ method calculate[bharath@gmail.com, com.sap.aii.mappingtool.tf7.rt.Context@26af720d] See error logs for details
Please give me the complete code so that I will get to know where I'm doing wrong,Im basically new to UDFs
I have used the above code and I have given the mail address as dummy, When I pass the actual mail ID to which we have to send the file in the payload.
I am getting this error
Transmitting the message to endpoint <local> using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.sdk.xi.srt.BubbleException: Failed to call the endpoint [null "null"]; nested exception caused by: java.io.IOException: server not responding OK to RCPT TO; 501 Syntax error - Badly formatted address
Hello Bharath,
Please check the below link
https://blogs.sap.com/2005/03/07/mail-adapter-xi-how-to-implement-dynamic-mail-address/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.