on 02-26-2016 10:06 AM
Hi guys,
I have an SOAP->Mail scenario and I have a problem with handling attachments and content in the same email. The issue is, that if I want to keep attachments which are sent with SOAP request, I need to check "Keep attachments" checkbox in receiver mail communication channel.
However, technically, Payload is also an attachment and the adapter adds payload also as an attachment instead keeping the body in the mail body.
So finally I end up with an email having no body and original attachment and payload attachment.
Any ideas how I could set up the adapter so I get a body with a proper content and required attachments?
I use Mail package and am on 7.31 version.
Thanks guys in advance,
Peter
Hi Peter
Unfortunately, this is indeed the behavior of the mail receiver adapter.
Therefore you'd need some custom development to get it to work, i.e. have an email body with attachments.
Following blog shows an example of constructing the MIME content of the email via Java mapping. It does not use Mail Package since Mail Package is deprecated.
However, if you insist on using Mail Package, you can refer to the link within the above blog as well as the solution in the following thread.
Regards
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the UDF I use to generate the Content element.
Sender CC I use soap sender - keep attachments needs to be checked
Receiver CC - Mail, mailpackage, keep attachments UNCHECKED
use the links from above to see how the content should be generated. Important is , that boundary in the content uses additional "--" String.
UDF has one parameter - boundary - in my case it is "--AaZz".
One input field - which is mapped to mailbody parameter - that is what I want to have in the mail body and not as an attachment.
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
String nl = "\r\n";
String result = "--" + boundary + nl + "Content-Type: text/plain; charset=UTF-8" + nl + "Content-Disposition: inline" + nl + nl+ mailbody;
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Iterator<String> IDsIterator = CollectionIDs.iterator();
while(IDsIterator.hasNext())
{
String AttachmentID = IDsIterator.next();
Attachment attachment = inputAttachments.getAttachment(AttachmentID);
String ct = attachment.getContentType();
result += nl + nl + "--" + boundary + nl;
result += "Content-Transfer-Encoding: base64" + nl;
result += "Content-Type: " + ct + nl;
result += "Content-Disposition: attachment; filename=" + ct.substring(ct.indexOf("name")+5);
result += nl + nl + attachment.getBase64EncodedContent();
}
}
return result + nl + nl + "--" + boundary + "--";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter
First of all, thank you for sharing back the solution that worked for you with the rest of the community.
Secondly, I need to apologize for my previous reply which sent you off to develop custom UDF to achieve your requirement. I've been debugging the mail adapter and figured out an alternative solution (that I've not been aware of before) that does not require custom Java coding. I've written more about it in the following article.
Regards
Eng Swee
Hi Peter,
Follow this URL. This will solve your problem.
Thanks,
Apu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
When you are sending message from SOAP to mail, then what should go as mail body and what should go as attachment.
Do you want the same message to go as body as well as attachment?
Regards,
Vikas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately it didn't. I have the same result - nothing in the body and 2 attachments, original one and the content of the COntent element in attachment named MainDocument.xml (and it is not unfortunately an XML at all.. which is strange nehaviour of standard adapter)
Any other suggestions please?
Thanks,
Peter
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.