Send email through outlook

Asked

Viewed 617 times

1

I am trying to send e-mail using outlook, through Delphi7, I used this Documentation: Command-line switches to open the 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:

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

  • What happens if you copy this into the text box in the Windows Run Dialog and press OK?

  • Same error as the message comes straight from Outlook. Thank you

1 answer

3


The problem is that the argument passed as /m need to be in quotes 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 must be executed is

C:\> outlook.exe /c ipm.note /m "[email protected]&subject=assunto&body=corpo"
  • Thank you very much, I tested in an example, with several emails, and a message with several lines, and opened the outlook sending message.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.