Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 May : Emailing with ShellAPI

www.cryer.info
Managed Newsgroup Archive

Emailing with ShellAPI

Subject:Emailing with ShellAPI
Posted by:"mcinwg" (mcinwgspam@googlemail.com)
Date:10 May 2008 04:01:54 -0700

I am attempting to send auto-generated emails from a D2006 Ent
Delphi32 project, using the following proc :

procedure TfrmCentral.btnShellEmailClick(Sender: TObject);
var
em_subject, em_body, em_mail : string;
R : integer;
P : pchar;
begin
  em_subject := 'Message_from_Home';
  em_body := 'Your_Photo_has_been_approved';

  em_mail := 'mailto:mcinwg@mailserver.com?subject='
             +em_subject
             + '&body='
             + em_body ;
  p := pchar(em_mail);

  R := ShellExecute(Self.Handle,nil,p, nil, nil, SW_NORMAL) ;
end;

Seems to work OK, both with 'nil' and 'open' as the second
parameter, opening up the default email program, awaiting
pressing of the 'Send' button.

But I have a problem with <spaces> : as above I have to replace
all spaces with underscores for correct behaviour.

- A space in the Subject string, opens the message with Subject
curtailed at the space, with no message body and also an open
browser window
- A space in the Body string, opens the message with Subject OK,
but with the message body curtailed at the space, and also again
with an open browser window.

Can anyone tell me/suggest how to correctly include spaces in the
strings ?

Also, can the message be sent automatically, without opening the
message window and awaiting the 'Send' button press ?

Thanks in anticipation.

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive