How to do a Drafts folder

About

Some mail user agents provide a so-called Drafts folder. The functionality of this folder comes down to a temporary folder where unfinished messages are stored.

The TnyPlatformFactory

In the Tinymail framework you have a platform factory type, the TnyPlatformFactory, which you can inherit from the available ones or which you can fully implement yourself.

The type, being a factory type, has a method called tny_platform_factory_new_msg which you must implement yourself.

In this implementation you can create an empty message in your Draft folder and return that instance.

Your TnySendQueue implementation

One more thing to keep in mind though: because of how you will usually want the sending of messages to work, you might want to move the message from the Drafts folder to the Outbox folder of your TnySendQueue implementation, right?

So the implementation of your tny_send_queue_add method can for example take the message out of that Drafts folder and put it in your Outbox folder.

You can of course inherit an existing TnySendQueue for this. You can also decorate an existing one (which is what I personally recommend for this feature). Or the code for handling your "Send" button can simply do this too, of course. Which might be less clean, but should also work.

I guess that "clean" here is subjective and I guess it's up to you, the E-mail client application developer.

References to related other documentation