New mail with multiple attachments with command line

Is there a way to create a new mail with multiple attachments  and /mailurl switch using command line?

Background: We are currently developing an Delphi-ERP System. Our customers should get the possibility to select an invoice e.g. and send it as mail with predefined recipient, subject, body-text and some additional PDF attachments. The mails should not be send directly with SMTP, they should be opend with the local mailclient so the final mails can be modified by the users before sending.

So far this is already working with command line for Outlook and Thunderbird. Now we like to implement this functionality for em Clients as well.

What I found so far:
MailClient.exe /mailurl "mailto:[email protected]?subject=hello&body=bodytext"
Creates new mail with predefined content but without attachments

MailClient.exe testattachment.txt
Creates a new empty mail with one single attachment

I was not able to find a way to create a new mail with multiple attachments and predefined content. Is it possible?

Thanks for your time and help!

We support two ways to accomplish that:

  1. The recommended way is to use the standard Windows Simple MAPI interface through the MAPISendMail function (https://docs.microsoft.com/en-us/windows/win32/api/mapi/nc-mapi-mapisendmailw).

  2. The alternative way is to create .eml file with the mail content in RFC 5322 format and header X-Unsent: 1. It can be opened through MailClient.exe /open file.eml and it will result in opening the mail as a draft ready to be sent.

1 Like

Thanks for sending me in the right direction. I will check some code samples for Delphi and share my results here.

SOLVED, this is the Delphi-Code that did it, using TSendMail:

SendMail1.Recipients.Add;
SendMail1.Recipients[0].Address := sTo;
SendMail1.Subject := sSubject;
SendMail1.Text.Add(sbody);
SendMail1.Attachments.Add(sInvoiceFilename);
SendMail1.Attachments.Add(‘C:\Users\gerno\Downloads\test.jpg’);
SendMail1.Execute;
SendMail1.Recipients.ClearAndResetID;
SendMail1.Text.Clear;
SendMail1.Attachments.Clear;

Additional Information: http://docwiki.embarcadero.com/CodeExamples/Rio/en/TSendMail_(Delphi)

Thanks for the help!

thank you for topic

work code in command line
“C:\Program Files (x86)\eM Client\MailClient.exe” “c:\test.txt” /mailurl “mailto:[email protected]?subject=hello&body=bodytext”