Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Email mit Shellexecute

  Alt 27. Nov 2015, 14:14
Von: http://www.martinstoeckli.ch/delphi/delphi.html

Delphi-Quellcode:
procedure Sto_OpenMail(const Address: String; const Subject: String = '';
  const Body: String = ''; const Cc: String = ''; const Bcc: String = '');
var
  slParameters: TStrings;
  sMailCommand: String;
  iParameter: Integer;
begin
  slParameters := TStringList.Create;
  try
  if (Subject <> '') then
    slParameters.Add('subject=' + Sto_UrlEncode(Subject));
  if (Body <> '') then
    slParameters.Add('body=' + Sto_UrlEncode(Body));
  if (Cc <> '') then
    slParameters.Add('cc=' + Cc);
  if (Bcc <> '') then
    slParameters.Add('bcc=' + Bcc);
  // bring parameters into a form like:
  // mailto:<address>?subject=<subjectline>&body=<mailtext>&cc=<address>&bcc=<address>
  sMailCommand := 'mailto:' + Address;
  for iParameter := 0 to slParameters.Count - 1 do
  begin
    if (iParameter = 0) then
      sMailCommand := sMailCommand + '?'
    else
      sMailCommand := sMailCommand + '&';
    sMailCommand := sMailCommand + slParameters.Strings[iParameter];
  end;
  ShellExecute(0, 'open', PChar(sMailCommand), nil, nil, SW_SHOWNORMAL);
  finally
    slParameters.Free;
  end;
end;
  Mit Zitat antworten Zitat