Richmail attachment gets corrupted

Richmail attachment gets corrupted


In a particular screen of my application there's a functionality to upload a file that latter may be sent by email, as an attachment.
There is also the possibility to download the file and save it to disk or open it right away.

This has proven to work fine up until now where the rich mail attachments seem to be corrupted. The download still works fine.
I am using the richmail extension and my email may contain 0 or many attachments.

Any ideas of what may have gone wrong and how to solve it?


Hi Nuno,

If you didn't change the code, the only thing I would think of would be the size of the attachments or - it's possible - a bug in the RichMail extension.

I don't really know what steps to suggest to try and troubleshoot the issue, so I'm going to shoot in many directions, hopefully one of them will help you:

- What are the sizes of the corrupt files? Are all the corrupt files the same size? It could somehow be a buffer problem.
- Have you tried doing a text-diff of the two files? that could shed some light towards what is causing the corruption as well. If you can, do zip two files (the good one and the corrupted one), and attach it to the forums - even if they are just dummy ones.
- Does this happen in all attachments? All file types?
- Finally, have you changed the code, and/or started using AJAX? This topic here covers a similar issue. Maybe it's similar to yours?

Let us know what you find.


Paulo Tavares
Hello Paulo,

On your questions,

It happens on all files, except possibly for very small sizes (ten's of bytes) or at least for txt files.
I was not able to spot any difference between text files I have created. They are very small in size, so I am not sure if this is a good test.
I was able to notice differences between PDF and XLS files; it looks like at a given point the file misses a CR and keeps on writing on the same line.
I am attaching two examples, one if for a TXT file that looks identical and another of a XLS file that is corrupted.
I am constantly changing the code, but this feature (of uploading and sending via email hasn't change for a while).
As for the AJAX; I have a LINK in the screen that invokes (via AJAX) an action within the screen.Then, this screen action calls up an user action that sends the email (first it reads the file from the database and then builds the email body with or without the attachment - the user action is the one the picture displays). I already changed the LINK method to SUBMIT but the results were the same. By the way, I am pretty sure the file is properly stored on the database as I am able to correctly download it and open it.

Thank you!
Hi Nuno,

I'm sorry, I didn't get your attachment.

Still, from your description, I'm not sure that I'll be able to go any deeper into that subject. Even though I'll appreciate if you can attach a zip file with the XLS files - the original and the corrupted one - I fear that this will have to go through our support department, since it could be either a bug in the Richmail extension, or they might need to get some more details on your current setup, in order to understand what's going on.


Paulo Tavares
You did get the file because I forgot to attach it... sorry.
Here it is.

Thank you,
Nuno Abreu
Hi Nuno,

I really can't make a thing out of the files, sadly, asides from the fact that - as you mentioned - that the files do not seem to be truncated, but corrupted indeed.

I'll send this over to our support department, but I recommend that you send them an e-mail directly as well about it, so that they can follow up directly with you.

Do let us know if you manage to figure out what is going on, and how to solve this.


Paulo Tavares
Hi Paulo,
Thank you!
Hi Nuno,

What version of the platform are you using? We had problems with corrupted e-mail with platform version > 5.0.19, which turned out to be a bug in the platform, solved in one of  the latest versions. You mention that it worked fine "up until now" - what is "now" and did you upgrade the platform in between?

Best regards,

Hi Nuno

Can you show the parameters you are passing to action RichMailCreate? I have been using RichMailCreate with attachments continuously for 4 years, through 5 different versions, and never had a problem. And I can tell you that the source code of RichMailCreate has been unchanged for quite a while...

Are you sure you did not change anything in your action?
What version of the Agile Platform are you using (e.g.

@Acacio: The problem was not in the RichMail, but in the MIME encoding, and appeared only on certain versions of Exchange.
Hi folks,

I noticed that this extension was "upgraded (?)" when I lastly uploaded a solution onto Production environment.
I downloaded the previous version from Production server and uploaded it directly onto Dev and richmail started working fine...
I am uploading some versions of this comp but only one seems to work fine.
This is being handled by OutSystems Tech Support but in between, if you what to have a look.

Cheers and thank you for your replies,
Platform is