Recent

Author Topic: Open mail client  (Read 12377 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1977
    • http://wiki.lazarus.freepascal.org/User:Zoran
Open mail client
« on: April 24, 2010, 08:03:46 pm »
Is there a way to open default mail client from application?
In Delphi ShellExecute can be used, but it works only in Windows.

I see that there is a very useful new function OpenUrl in LCLIntf unit, for opening default browser... But I can't find similar function to open e-mail client...

Is there a way to acchieve this?
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Open mail client
« Reply #1 on: April 25, 2010, 06:22:29 am »
in OSX command "open -a Mail" can be used.

This isn't reliable, because some other email client can be used.
« Last Edit: April 25, 2010, 06:24:05 am by skalogryz »

Zoran

  • Hero Member
  • *****
  • Posts: 1977
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Open mail client
« Reply #2 on: April 25, 2010, 08:13:05 am »
in OSX command "open -a Mail" can be used.

This isn't reliable, because some other email client can be used.

Thank you, Skalogryz, it's quite acceptable solution, as long as some email client opens, but, I see now that I did not explain clearly what I want, sorry.
I need a new message window to open with email address I provide in application. Can I add address parameter to this command?

And... How to achieve this in Linux?

In Windows, this is acchieved with:
Code: [Select]
ShellExecute(Handle,'open','mailto:myadress@xxxxxx.com',nil,'',SW_SHOWNORMAL);
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

davesimplewear

  • Sr. Member
  • ****
  • Posts: 321
    • Davids Freeware
Re: Open mail client
« Reply #3 on: April 25, 2010, 09:16:38 am »
use the TProcess and give executable of mail client : e.g.

Code: [Select]
var
aProcess:Tprocess;
begin
  AProcess := TProcess.Create(nil);
  AProcess.CommandLine := 'thunderbird';
  AProcess.Options := AProcess.Options + [poWaitOnExit];
  AProcess.Execute;
  AProcess.Free;
end;
All things considered insanity seems the best option

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Open mail client
« Reply #4 on: April 25, 2010, 09:30:13 am »
This works only if you knows that the user have installed thunderbird as email client. If it have installed another email client, don't works ...

Zoran

  • Hero Member
  • *****
  • Posts: 1977
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Open mail client
« Reply #5 on: April 25, 2010, 09:42:39 am »
Of course I don't know which mail client is installed on users computer.

Does something like "default mail client" actually exist on Linux? If it does, there will be a way to get it...
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12566
  • FPC developer.
Re: Open mail client
« Reply #6 on: April 25, 2010, 10:16:23 am »
Of course I don't know which mail client is installed on users computer.

Does something like "default mail client" actually exist on Linux? If it does, there will be a way to get it...


Unix is layered there. The most common layer to maintain such system wide defaults is freedeskop, which provides the xdg-* binaries and are honoured by both kde and gnome.  In this case, have a look at "xdg-email"

Afaik Firefox can maintain an own setting which email-client to open, but possibly it depends on how it is compiled.

Probably something like openurl needs to be added to lclintf.

davesimplewear

  • Sr. Member
  • ****
  • Posts: 321
    • Davids Freeware
Re: Open mail client
« Reply #7 on: April 25, 2010, 11:27:13 am »
here is the way i get around it, in a user setup get them to input the eamil client name and save it to a db and use the name as the exexcutable for the email client the thunderbitrd above was an example.

Code: [Select]
procedure TfAdmin.sbEmailClick(Sender: TObject);
var
aProcess:Tprocess;
begin
  AProcess := TProcess.Create(nil);
  AProcess.CommandLine := dmData.TSetupEMAILCLIENT.Value;
  AProcess.Options := AProcess.Options + [poWaitOnExit];
  AProcess.Execute;
  AProcess.Free;
end;
All things considered insanity seems the best option

Zoran

  • Hero Member
  • *****
  • Posts: 1977
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Open mail client
« Reply #8 on: April 26, 2010, 07:41:43 am »
Unix is layered there. The most common layer to maintain such system wide defaults is freedeskop, which provides the xdg-* binaries and are honoured by both kde and gnome.  In this case, have a look at "xdg-email"

Afaik Firefox can maintain an own setting which email-client to open, but possibly it depends on how it is compiled.

Okay, I'll see about xdg, thank you.

Probably something like openurl needs to be added to lclintf.

Yes, it would be very useful.

Thank you all!
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

 

TinyPortal © 2005-2018