Send email through outlook

1

I'm trying to send mail using Outlook, through Delphi7, I've used this Documentation: Command-line switches to open outlook with message parameter passing, conforms below:

var
  para,assunto,mensagem : string;
begin
  para := '[email protected]';
  assunto := '&subject='+'Contato secreto sobre o assunto';
  mensagem := '&body='+'Bom dia,
                        contato recebido com sucesso';

  WinExec(PChar('C:\Program Files\Microsoft Office\Office16\outlook.exe '+'/c ipm.note /m '+para+assunto+mensagem);
end;

But when I send, it returns the message:

  

Can not start Microsoft Outlook.   The command line argument is not valid. Check the   options used.

    
asked by anonymous 20.03.2017 / 12:39

1 answer

3

The problem is that the argument passed as / m must be enclosed in quotation marks in newer versions of Outlook

WinExec(PChar('C:\Program Files\Microsoft Office\Office16\outlook.exe '+'/c ipm.note /m "'+para + assunto + mensagem + '"');

Basically, the command that should be executed is

C:\> outlook.exe /c ipm.note /m "[email protected]&subject=assunto&body=corpo"
    
20.03.2017 / 12:58