It is maybe even possible without downloading the emails from the server using a server based threading?
Nope, at least not using IMAP protocol - it is used for client access. It is not possible to program server side extensions with it.
Is this possible using the functionality of Mail.dll?
Yes, what you need to do is to download message, modify it, delete the original and upload it again.
For some short time (depending on your implementation) original message would be still visible in the INBOX though.
Yu can read more on uploading emails using IMAP here:
You'll need to use UploadMessageInfo class, so you can set unseen flag and internal server date:
UploadMessageInfo messageinfo = new UploadMessageInfo();
imap.UploadMessage("INBOX", email, messageinfo);
To modify message's text/html:
IMail email = ....
email.TextData.Text = "modified text";
email.HtmlData.Text = "modified <strong>html</strong>";
Remember to make sure that IMail.TextData/IMail.HtmlData are not null. Emails may contain several versions of the body in different formats (text/html/rtf) or only one such format.
Some additional notes:
- If message is signed/encrypted you shouldn't do anything as it will break the message
- DKIM signature is going to be invalidated, if you modify the message