From my experience, mail clients are not generally intended to provide a mechanism for sending mail messages from external sources in an automated manner — rather they are designed to enable users to compose messages inside their own environment. You can however create an .EML file and separately open this with more or less any mail client, including Thunderbird. EML is primarily a form of archive, intended to provide a method of saving e-mails as an external file, but you can still open them and send them onwards, in the mail client. You could for instance send it using ‘forward’. It isn't ideal.
The .EML file format is easily constructed though and you could create the following text file in PureBasic and write it using a serial number, or whatever, into a folder, which you can then open later. A working example would be as follows (note the blank line is required) :
Code: Select all
From: <Kraut@email.com>
To: <me@email.com>
Date: Sun, 24 Sep 2023 14:50:00 +0700
Subject: Test message to you
Hello, this is the main e-mail body text
There are far better ways of doing this however, but I’m providing the above since you may have a specific need to do this within Thunderbird. Adding attachments is more difficult using this method, as you would need to encode them using Mime headers (Mime64 or Uuencode could be used).
1. Don't use .EML — instead just write a file containing the body text of the message and then use Blat to send it. This works differently, because you instead specify the attachments, the sender's parameters, the receiver's parameters and the subject, in the form of directives on the Blat command line.
2. Use a mail server (there are several) providing the means of polling an import folder. For example the old Mailtraq mailserver is good at this and provides the 'Pending' sub-folder primarily for this purpose. Mailservers will usually expect to be provided with the mail headers, such as in the above example, so they differ somewhat from say Blat, which doesn't require this.
Blat is easier to use, or you could write your own sending process with PureBasic, since PureBasic already provides a mail sending function. As your specific requirement is to send messages later, as you say, then presumably you have a known point in time when those messages can be sent. I take it that you don't want to immediately send the message in PureBasic (even though it can do so), so you wish to send it later. You could do that yourself by writing a PureBasic background process that picks up queued messages and sends them. I hope this helps.