I am currently using Delphi 7 on XP, but I would like to eventually migrate the code to DXE on Win8.
I am trying to send email using the JCL, using JCLMAPI to be specific. I tried using the JclSimpleSendMail
routine in the JCLMAPI unit. Here's the interface to the call.
function JclSimpleSendMail(const Recipient, Name, Subject, Body: AnsiString; const Attachment: TFileName; ShowDialog: Boolean; ParentWND: THandle; const ProfileName: AnsiString; const Password: AnsiString): Boolean;
The problem is it pops up the default MAPI client message box modally (in my case Outlook 2010). I would like it to just open the email message window, but allow the user to continue working in the Delphi App. until they are ready to send, eg, in case a user wants to continue working in the Delphi App before sending the email. Is this possible?
I noticed there is a ParentHWND property in TJCLEmail, I tried setting that to zero (I know it was a reach), but I was hoping that removing the parent handle might change the modal behavior (no luck!)
function TForm1.SimpleSendHelper2(const ARecipient, AName, ASubject, ABody: AnsiString; const AAttachment: TFileName;
AShowDialog: Boolean; AParentWND: THandle; const AProfileName, APassword, AAddressType: AnsiString): Boolean;
var
AJclEmail: TJclEmail;
begin
AJclEmail := TJclEmail.Create;
try
**AJCLEmail.ParentWnd := 0; //TRIED FORCING THE ATTACHED HANDLE TO ZERO**
*//if AParentWND <> 0 then
// AJclEmail.ParentWnd := AParentWND;*
if ARecipient <> '' then
AJclEmail.Recipients.Add(ARecipient, AName, rkTO, AAddressType);
AJclEmail.Subject := ASubject;
AJclEmail.Body := ABody;
if AAttachment <> '' then
AJclEmail.Attachments.Add(AnsiString(AAttachment));
if AProfileName <> '' then
AJclEmail.LogOn(AProfileName, APassword);
Result := AJclEmail.Send(AShowDialog);
finally
AJclEmail.Free;
end;
end;
This also successfully opened up the Default MAPI app and filled in all of the information passed (TO, Subject, Body, Attachment). Unfortunately it still opens the message box modally.
Finally, I also tried the code at http://www.delphifaq.com/faq/delphi/network/f236.shtml This code just Uses MAPI directly (no JCL). Unfortunately, it also pops up the message box modally.
Any thoughts on how I can open the default MAPI client non-modally?
Thank you!