0

Trying to use NodeMailer to create a Draft email in Apple Mail.

The following approaches have not yet been successful:

  • Using NodeMailer's mail option saveToDrafts: true
  • Saving an email as a .eml file in the Finder, using AppleScript to open the file and convert it to a Draft (Note: Creating and opening in Apple Mail works just fine, but the result is a read-only, unsendable email that must be converted manually to a Draft using Apple Mails "Move to..." button. Trying to get rid of that manual step.
WhatsYourFunction
  • 621
  • 1
  • 9
  • 25
  • With your second approach, could you not also have the applescript move the message into the Drafts folder? – Mockman Dec 27 '22 at 15:10
  • Possibly, but I haven't figured out how to do that yet. If so, problem solved!! – WhatsYourFunction Dec 28 '22 at 13:43
  • Perhaps something like this: `set mailbox of theMessage to mailbox "Drafts"`. Saw it in another question. – Mockman Jan 01 '23 at 01:19
  • In AppleScript that doesn't work for an .eml file created by Nodemailer's on the Desktop, opened in Apple Mail directly, at least not in an obvious way. An .eml opened from the Finder isn't seen as an email object by AppleScript (comes up as 'Missing Value'), so there's no way to perform any operations on it. – WhatsYourFunction Jan 02 '23 at 02:38
  • Interesting. What about scripting ui elements for the 'move' button? – Mockman Jan 02 '23 at 17:29
  • Maybe. How would you see that playing? (btw I got it to work by other -- possibly better means, but banking up multiple solutions always good / usually pays off down the road) The challenge with a AppleScript as a solution (so far) is simply seeing/handling the externally-created .eml file. It would be a cool nut to crack. – WhatsYourFunction Jan 03 '23 at 18:34
  • 1
    Well, something like this: [access Safari's "Reload this page" button](https://stackoverflow.com/questions/75016176/applescript-access-safaris-reload-this-page-button-update) but for Mail's 'move to' button instead of this one in Safari. – Mockman Jan 06 '23 at 16:19
  • 1
    Thanks for sharing that one. The "Move To" will have the added challenge of its sub-button where you choose where to move it to, but good to know about that ability to iterate through UI buttons via Apple Script! – WhatsYourFunction Jan 07 '23 at 06:43

1 Answers1

0

NodeJS package imapflow's append can be used to push an .eml file (created, say, by nodemailer's mailcomposer).

WhatsYourFunction
  • 621
  • 1
  • 9
  • 25