Create emails in command line with Outlook.exe

André LE GAL 0 Reputation points
2023-03-12T17:31:45.71+00:00

Good morning

Do you know how it is possible to create emails (with batch, powershell or VBA or other) on the command line with Outlook.exe or other emails?

I tried outlook.exe but I can't join (attach) two attachments (pdf, doc, etc)

: outlook.exe /a "file1" /a "file2" ? : outlook.exe /a "file1", "file2" ? : outlook.exe /a "file1", "file2" ?

I don't know how to create these messages in a mailbox previously created or not (drafts box) then open Outlook to go to this mailbox to check them and then send them.

Or how create ans send a message to a mailbox ( via SMTP protocol) with WINDOWS 10

Thank you for your information if you have already had to create emails quickly with a script (and text data)

Cordially

Andrew

Outlook Windows Classic Outlook for Windows For business
{count} votes

1 answer

Sort by: Most helpful
  1. Yuki Sun-MSFT 41,376 Reputation points Moderator
    2023-03-13T06:12:33.6+00:00

    Hi @André LE GAL,

    You can use the Send-MailMessage cmdlet to send mails from within PowerShell. Per my test, multiple attachments can be included in this method.

    Below is a sample code which can be run from the command prompt:

    powershell send-mailmessage -to '******@contoso.com' -from '******@contoso.com' ^
    -subject 'Test email' ^
    -SmtpServer 'smtp.contoso.com' ^
    -attachment 'file1', 'flie2'
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.