some problems with email attachments

Poster Content
nk4um User
Posts: 37
November 18, 2014 11:43solved

Finally I solved the problem using a dedicated service that serve the static file resource and set mime type different than "text". Thanks for your support!

Like · Post Reply
nk4um User
Posts: 37
November 18, 2014 09:09

The problem is more business related than technical. I simply wish to allow the person who will receive the email to download the attachment ...

If it is attached as file that's simple. Otherwise he will need to copy the part from email and past it in an editor, and so on ..., which is not quite user friendly ...

As I noticed the <attachment node has <name and <filename children. Not sure how to specify the mime-type ... Perhaps instead using a simple static file resource to use a service which provides additional mime-type?! I think I will have a trial in this direction ...

Kind regards,

Radu

P.S. Sorry for delay I was focused on a different topic and I forgot to follow the forum

Like · Post Reply
nk4um Administrator
Posts: 607
November 4, 2014 21:24

Thanks Menzo, I think the code is pretty much unchanged from NK3. Yes I can see what you are doing here and yes the current code assumes that it the mimetype of the argument is text/* then it is added to the email without a filename. So maybe that is the fix - the code should make the decision based on if the attachment is setup rather than the mimetype.

Radu what are you attaching that is not working is it plain text or some other text/* mimetype?

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 111
November 4, 2014 21:09NK 3 patch to send text as an attachment

Hi,

A long time ago I did a fix for NK3 to enable the sendmail accessor to send text as an attachment. I'm not sure how close the NK5 codebase is to NK3, but here is the diff:

Menzos-MacBook-Pro-2:accessor menzowindhouwer$ diff BaseSMTPAccessor.java ~/Documents/Projects/other/src/NetKernel/src/modules/mod-smtp-1.1.2/org/ten60/smtp/accessor/BaseSMTPAccessor.java
0a1,5
> /****
>  * CHANGELOG
>  * [12/4/2008 maw] Made it possible to also send attachments with MIME
>  *                 type text/*
>  ****/
154,156c159,160
<                     if( rep.getMeta().getMimeType().startsWith( "text" ) ) {
<                         dh = new DataHandler( baos.toString(), rep.getMeta().getMimeType() );
<                     } else {
---
>                     if( !rep.getMeta().getMimeType().startsWith( "text" ) || aHelper.getOperand().getXDA().isTrue( "//attachment[name='" + struct.getKey() + "']") ) {
>                         System.err.println("DBG: "+struct.getKey()+":handled as attachment");
164a169,171
>                     } else {
>                         System.err.println("DBG: "+struct.getKey()+":handled as part");
>                         dh = new DataHandler( baos.toString(), rep.getMeta().getMimeType() );

If you want the complete file just let me know.

Maybe this helps,

Menzo

Like · Post Reply
nk4um Administrator
Posts: 607
November 4, 2014 20:13

Hi Radu,

looking at the source code for the sendmail accessor it looks like the attachment tag only overrides the name of the multipart part within the email structure. I see nothing superficially in the api to control how the parts are handled or even if they can be controlled. It's a long time since anyone has dug into this API. If this is important to you and you have the time place take a look at what it would take to get the desired functionality then we can incorporate it into the accessor.

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 37
November 4, 2014 09:16some problems with email attachments

Hi!

Just tried to add an attachment to an email using the active:sendmail service.

So I added a

<attachment>
  <name>partName&lt;/name&gt;
  <filename>fileName&lt;/filename&gt;
&lt;/attachment&gt;

and I provided the attachment content via partName request argument.

The email was sent, but the content of the attachment is inserted in the email body.

When I inspected the raw form of the email there is no occurence for the fileName value ... (which makes me judge that the mode that I create the email was wrong since the part is not seen as an attachment having a filename).

Any idea how to force the attachment to be sent as attachment and not included in the body?!

Thanks in advance for any hint/tip/suggestion.

Kind regards,

Radu

Like · Post Reply