Bug 1578801 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

In Thunderbird 68 Attachments can be deleted/detached with the following function:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true // save
);

This function opens mandatory a dialog to choose a save path, when the last attribute is set to true to save the detached files.

To call this function for bulk operations it would be necessary to have an additional attribute for the save path instead of the mandatory save path dialog.

The function call could be like this:

messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  predefinedSavePath  // [optional]; if unset the save path dialog should be opened
);

This predefinedSavePath could be used in my addon "AttachmentExtractor Continued" for example. Then the addon would be able to use Thunderbirds internal detach routine and the deleted attachments could still be linked to the original messages (which is an improvement in Thunderbird 68).

For reference:
https://searchfox.org/comm-central/search?q=detachAllAttachments
https://searchfox.org/comm-central/source/mail/base/content/msgHdrView.js#3238
https://searchfox.org/comm-central/source/mailnews/base/src/nsMessenger.cpp#2651
In Thunderbird 68 Attachments can be deleted/detached with the following function:

```javascript
messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true // save
);
```

This function opens mandatory a dialog to choose a save path, when the last attribute is set to true to save the detached files.

To call this function for bulk operations it would be necessary to have an additional attribute for the save path instead of the mandatory save path dialog.

The function call could be like this:

```javascript
messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  predefinedSavePath  // [optional]; if unset the save path dialog should be opened
);
```

This predefinedSavePath could be used in my addon "AttachmentExtractor Continued" for example. Then the addon would be able to use Thunderbirds internal detach routine and the deleted attachments could still be linked to the original messages (which is an improvement in Thunderbird 68).

For reference:
https://searchfox.org/comm-central/search?q=detachAllAttachments
https://searchfox.org/comm-central/source/mail/base/content/msgHdrView.js#3238
https://searchfox.org/comm-central/source/mailnews/base/src/nsMessenger.cpp#2651
In Thunderbird 68 Attachments can be deleted/detached with the following function:

```javascript
messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  true // [optional] delete / detach without confirmation
);
```

This function opens mandatory a dialog to choose a save path, when the last attribute is set to true to save the detached files.

To call this function for bulk operations it would be necessary to have an additional attribute for the save path instead of the mandatory save path dialog.

The function call could be like this:

```javascript
messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  true, // save
  true, // [optional] delete / detach without confirmation
  predefinedSavePath  // [optional]; if unset the save path dialog should be opened
);
```

To be more backwards compatible the predefinedSavePaht maybe could be combined in an array with the boolean attribute for save=true:

```javascript
messenger.detachAllAttachments(
  attachmentContentTypeArray.length,
  attachmentContentTypeArray,
  attachmentUrlArray,
  attachmentDisplayNameArray,
  attachmentMessageUriArray,
  [true, predefinedSavePath],  // if true, the predefinedSavePath could be optional
  true // [optional] delete / detach without confirmation
);
```

This predefinedSavePath could be used in my addon "AttachmentExtractor Continued" for example. Then the addon would be able to use Thunderbirds internal detach routine and the deleted attachments could still be linked to the original messages (which is an improvement in Thunderbird 68).

For reference:
https://searchfox.org/comm-central/search?q=detachAllAttachments
https://searchfox.org/comm-central/source/mail/base/content/msgHdrView.js#3238
https://searchfox.org/comm-central/source/mailnews/base/src/nsMessenger.cpp#2651

Back to Bug 1578801 Comment 0