Closed Bug 1593012 Opened 5 years ago Closed 2 years ago

Create an Email and Save it to a Folder (IMAP)

Categories

(Thunderbird :: Add-Ons: Extensions API, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1545930

People

(Reporter: michaelpopepublic, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0

Steps to reproduce:

Nothing yet, this is an enhancement.

Actual results:

Nothing yet, this is an enhancement.

Expected results:

It'd be nice to be able to have an API to create/reply/forward an email and to save it to a folder (kinda like a Draft, but necessarily to the drafts folder).

I'm sure there are quite a few uses for this, but the main reason I'm interested in this is because it would allow us to save extension settings and have it synchronize over IMAP.

For example, let's say I wanted to write an extension to remind me to check an email in a few days. I could 'reply' to a message, and save that draft to a specific folder. Then, because of the IMAP sync, on that device (or another device), in a couple of days, I could check the messages in that folder and emit a reminder.

As of such, for any extension you have, you could really easily save any settings you wanted to be synchronized, and not have to run an independent couchdb/gundb instance or something like that (which is great for users)

This may not be a usual use for IMAP (it wasn't built for this, and it'd be slow)... but I'm pretty sure it would work. As of now, you can copy or move emails into an IMAP account, and they'll get uploaded just fine. This just piggybacks off of that to allow us to synchronize extension settings.

Typo in my previous comment. *NOT necessary to the drafts folder.

To clarify, again , this is probably pretty similar to API to Send Messages (Bug 1545930), which allows an extension to send an email in the background. The difference is that rather than allowing an extension to send an email, it allows an extension to save an email to a folder (still in the background).

Being able to use it as a reply or forward would also be nice, but probably extra credit, so to say. I'd be thinking of an API added to compose like the following or something:

`
//for creating
browser.compose.beginNewBackground(details)
.then(function(messageYouCanEdit)
{
//do some stuff with methods you can use to edit the message

//save the message to a folder
messageYouCanEdit.saveToFolder(folder);

//I'd also assume you could send it here, and cover Bug 1545930

}).catch(function(error)
{
});
//for replying and forwarding, these might work
browser.compose.beginReplyBackground(message.id, replyType, details)
browser.compose.beginForwardBackground(message.id, forwardType, details)
`

We shouldn't be creating an API like this just for extensions to hack around the fact there's no Sync at the moment - if we want Sync for extensions, we should do that properly and spend the time on it, rather than doing something that would potentially confuse a user and that isn't designed for settings synchronisation. Having a proper sync would also mean that extensions don't need to manage the actual Synchronisation themselves.

(In reply to Mark Banner (:standard8) (afk until 13 Aug) from comment #3)

We shouldn't be creating an API like this just for extensions to hack around the fact there's no Sync at the moment - if we want Sync for extensions, we should do that properly and spend the time on it, rather than doing something that would potentially confuse a user and that isn't designed for settings synchronisation. Having a proper sync would also mean that extensions don't need to manage the actual Synchronisation themselves.

That would be ideal of course. I'm just not quite sure that sync will come to Thunderbird. We'll have to see - I don't want to add things to your guys' plates, as I'm pretty sure Sync would be a lot of work to implement.

In any case, since I wrote this, I have actually implemented it partially (still a WIP). While I do very much agree that IMAP and email messages aren't designed for this, I do have to admit, that there is one advantage. It's pretty much a zero-config thing - people don't have to sign into services (like Firefox Accounts) or host their own software (like the Firefox Accounts backend, which is open source and has a name which is escaping me right now :p). It just sorta works. On the other hand, it puts a lot of responsibilities on the extension writer to not hammer people's computers and email servers.

Anyways, just my two cents, and thanks for looking at this. Hope your having a great day!

Thunderbird 102 has compose.saveMessage(), which allows saving the currently composed message as draft or template. You get a handle of the saved message and can move it to a different location. Does that fulfill your request?

We currently do not have an API for background message operations (sending/saving) without opening a compose Window. This is planned in Bug 1545930.

Can you state whether this Bug is fixed for you with compose.saveMessage() or if this can be handled a duplicate of Bug 1545930?

Flags: needinfo?(michael.pope.email)

(In reply to John Bieling (:TbSync) from comment #5)

Thunderbird 102 has compose.saveMessage(), which allows saving the currently composed message as draft or template. You get a handle of the saved message and can move it to a different location. Does that fulfill your request?

We currently do not have an API for background message operations (sending/saving) without opening a compose Window. This is planned in Bug 1545930.

Can you state whether this Bug is fixed for you with compose.saveMessage() or if this can be handled a duplicate of Bug 1545930?

Yeah, it'd definitely fall under Bug 1545930 (from what I've seen from my WIP, background send would have an option to Save to Draft, which would cover most of this (I could save to draft, then move to folder)). So we can close this if you'd like.

Flags: needinfo?(michael.pope.email)
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE

I would be interested in your WIP background send. Can I find it somewhere to have a look?

(In reply to John Bieling (:TbSync) from comment #8)

I would be interested in your WIP background send. Can I find it somewhere to have a look?

Sure, although I don't remember if it's completely working in the version that's in source control. You'll need to give it a test. I'll try and see if I can find a more up to date version (if one exists) on my older computer later this week though:

Here's the link: https://github.com/MichaelEPope/thunderbird-compose-experiement/blob/main/composeExperiment.js

One thing I think which will need to be changed is line 66. I think it's supposed to be 'composeFields.body = (details.message) + "\r\n";' or something like that. As said though, I'll look.

@John Bieling
The API by Michael Pope is a very limited subset of the API used by my own add-on Mail Merge.

You need to log in before you can comment on or make changes to this bug.