How could I create email drafts?
I’ve been trying to find out how I can save emails as drafts using php in outlook.
By executing script draft email is generated on outlook draft section and i can send the email any time if required.
How could I create email drafts?
I’ve been trying to find out how I can save emails as drafts using php in outlook.
By executing script draft email is generated on outlook draft section and i can send the email any time if required.
2
Answers
This kind of question is way too open-ended for SO, but here’s a top-level view of what you could do.
You could create a message with PHP and upload it to your drafts folder via Outlook’s API or IMAP (there is an example of doing this for sent messages in the PHPMailer gmail example).
Conversely, you could create and save a draft in Outlook, then access it through an API or IMAP to pull it into your PHP script where you can do what you like with it, including sending it or uploading to another account.
See: the Graph API docs
Which you can use via their PHP SDK:
composer require microsoft/microsoft-graph
You basically just need to make sure
isDraft
is set to true, and then the message will go into your Drafts folder.