cancel
Showing results for 
Search instead for 
Did you mean: 

How to Attach the payload using Mail Attribute in receiver Mail adapter

former_member213558
Active Participant
0 Kudos

Hi All.

Scanario: SFTP to Mail adapter.

My requirement is whenever file comes i need to send the same file as attachment with the same file name using MAIL adapter. and the body of the content should be like as below.


" Dear Team XXXX has been placed to SFTP please check, here XXXX = same file name which we received from SFTP".


present set up.

1. I enabled  "Use mail package" option in receiver MAIL CC.

      so with out enabling "Keep Attachment" this setup working fine and i can able to see above mentioned content of the body. to read the file name we used the UDF at mapping level.

but when ever i do select "Keep Attachment" my body of the content is attached as a attachment of the mail.

can you please guide further.

mapping



udf used for getting File name.

configuration


note: both side ASMA is enabled

output

note: this attachment is not the one which i received from SFTP, this attachment is actually body of the content.



hope i given some inputs to  analysis this issue.


finally i need attachment as well as body of the content.


please help further.


Regards

Ramesh.


Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Ramesh

Just curious, you mentioned that the set up is working fine when you disable "Keep Attachments". So why then do you want to use it with "Keep Attachments" enabled?

Anyway, I won't provide a solution based on your current set up, but will instead suggest you to follow my post below because Mail Package is deprecated. Your requirement falls into the Scenario 3 category.

However, for your case since only 1 file is picked up by the SFTP adapter which needs to go as an attachment, you will need to use Java mapping to:-

i) Formulate the body content as the main document

ii) Copy the file contents and put it in an attachment. (There are many samples of how to create an attachment from Java mapping on SCN, but do shout if you need help here)

Regards

Eng Swee

Former Member
0 Kudos

Hi Eng Swee,

Just for my knowledge kindly correct me if I am wrong.

Can we use XIPAYLOAD as the message protocol in the receiver mail adapter, in order to get the payload as attachment in this case.

Your valuable suggestion will be really appreciable. Thanks.

Regards,

Souvik

Former Member
0 Kudos

Hi Eng Swee / Experts,

Kindly confirm.

Regards,

Souvik

apu_das2
Active Contributor
0 Kudos

Yes use XIPAYLOAD.

engswee
Active Contributor
0 Kudos

Hi Souvik

If you have queries of your own, please create your own discussion thread separately.

Regards

Eng Swee

former_member213558
Active Participant
0 Kudos

Thank you for your reply Eng.

Just curious, you mentioned that the set up is working fine when you disable "Keep Attachments". So why then do you want to use it with "Keep Attachments" enabled?

when i disable the "Keep Attachment", only body of the content is coming perfectly not Attachment.

my requirement is:

when ever file reach SFTP, i need to send the mail with same payload as attachment, and body of the content like " File XXXX (actual file name which we are taking from SFTP) " to be placed in SFTP please process the file" .

so that i tried with both combination of "Use mail package" and "Keep Attachment".

but when i try with these combination, instead of actual payload as attachment i'm getting BODY of the content as attachment.

if i keep only "Keep Attachment", by the time i can able to see the actual payload as a attachment, but the expected body of the content unable to display.


but the actual requirement is attachment along with the above mentioned body of the content.

please do needful Eng.

engswee
Active Contributor
0 Kudos

Hi Ramesh

I've already provided my inputs above which is based on not using Mail Package.

You can try that and let me know if you face any issues with that approach.

If you want to still proceed with using the deprecated Mail Package approach, I won't be able to assist with that.

Regards

Eng Swee

former_member213558
Active Participant
0 Kudos

thanks for your reply.

yes, i'm also looking for the option without mail package option once i read your blog.  Excellent!

so first, i keep with attachment option, for getting a proper BODY  i need to go for java mapping. correct me if i'm wrong. one request, in mentioned link display the body with actual payload not what i'm expecting, do we have any link to get any similar output? else please suggest the how to pass only body of the content using java mapping.

engswee
Active Contributor
0 Kudos

Hi Ramesh

I'm not sure if I understand you correctly. But I think you are asking how to construct the body of the email as the main document.

You can achieve this by creating a plain text output for the main document - a simple example below.


public void transform(TransformationInput input, TransformationOutput output) throws StreamTransformationException { 

  InputStream inStream = input.getInputPayload().getInputStream(); 

  OutputStream outStream = output.getOutputPayload().getOutputStream(); 

  try { 

   String body = "This is the body of the email";

   outStream.write(body.getBytes("UTF-8")); 

  } catch (Exception e) { 

   throw new StreamTransformationException("Exception: " + e.getMessage(), e); 

  } 

Note that the above logic only deals with the body, for the attachment, you need to add logic to copy the original payload and create a new attachment in to the message.

Regards

Eng Swee

Answers (0)