Link to home
Start Free TrialLog in
Avatar of rainbowsoftware
rainbowsoftware

asked on

Creating a new e-mail from Delphi

I have got an application, where following procedure works fine with MS I.E. ver. 4, but after upgrading to ver. 5. it doesn't work any more. Everything (To, Cc, Bcc, Subject and Content) is placed in the To-field in the e-mail.
Anybody got an idea, what I have to change?

function TForm1.CreateMail( sSubject : string; rgTo, rgCc, rgBcc, rgContent : TStrings ) : Boolean;
var
  sTo, sCc, sBcc, sContent, sURL : string;

  function LinesToStr( rgs : TStrings; const sDelim : string ) : string;
  var
    iIndex          : Integer;
  begin
    Result := '';
    for iIndex := 0 to rgs.Count - 1 do
    begin
      Result := Result + rgs[ iIndex ];
      if ( iIndex < rgs.Count - 1 ) then Result := Result + sDelim;
    end;
  end;

begin
  Result := False;
  if not ( Assigned( rgTo ) and Assigned( rgCc ) and Assigned( rgBcc ) and Assigned( rgContent ) )
    then Exit;
  sTo := LinesToStr( rgTo, '; ' );
  sBcc := LinesToStr( rgBcc, '; ' );
  sCc := LinesToStr( rgCc, '; ' );
  sContent := LinesToStr( rgContent, '%0D%0A' );
  sURL := 'mailto:' + sTo;
  if ( sBcc <> '' ) then sURL := sURL + '&bcc=' + sBcc;
  if ( sCc <> '' ) then sURL := sURL + '&cc=' + sCc;
  if ( sSubject <> '' ) then sURL := sURL + '&subject=' + sSubject;
  if ( sContent <> '' ) then sURL := sURL + '&body=' + sContent;
  Result := ShellExecute( 0, 'Open', PChar( sURL ), nil, nil, SW_SHOWNORMAL ) > 32;
end;
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Epsylon
Epsylon

Are you still there?
Avatar of rainbowsoftware

ASKER

Thanks a lot, now it works.
Joern