Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-12

Universal using of mailto:

10 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ireneusz Wyglądała

Hi All.
I have an small, cross platform application (linux and win32). I just wonder how can I implement universal function to sending mails to me. Of course by default mail program.

win32 - is simple
ShellExecute(Handle,'open','mailto:?Subject=Subject', nil, nil, 1);

But is there any universal method that works fine in linux and win32?

;) Irek -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081210/8d5d67dc/attachment.html

Reply by email

Graeme Geldenhuys
to Ireneusz Wyglądała

2008/12/10 Ireneusz Wygl?da?a :

But is there any universal method that works fine in linux and win32?

Linux is easy as well! ;-)
If your target Linux system has xdg-utils you can use the following command: xdg-email

-----------------------------------------------
$> xdg-email
xdg-email - command line tool for sending mail using the user's preferred e-mail composer

Synopsis

xdg-email [--utf8] [--cc address] [--bcc address] [--subject text] [--body text ] [--attach file] { mailto-uri | address(es) }

xdg-email { --help | --manual | --version }

Use 'man xdg-email' or 'xdg-email --manual' for additional info. -----------------------------------------------

If your target linux distro doesn't include Xdg-Utils, it is recommended that you deploy it with your application (help promote the idea and make live easier for software developers). If very simply to do and is described in the following website.
http://portland.freedesktop.org/wiki/

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Linux is easy as well! ;-) If your target Linux system has xdg-utils you can use the following command: xdg-email

I forgot to mention: xdg-email --manual
will explain in details how to use it, return values and what they mean and even a link to help the user setup there mail if it doesn't work.
http://portland.freedesktop.org/wiki/EmailConfig

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Ireneusz Wyglądała
to Graeme Geldenhuys: 2008/12/10 Ireneusz Wygl?da?a : Linux is easy as well! ;-) If your target Linux system…
Graeme Geldenhuys wrote 10 lines
2008/12/10 Ireneusz Wygl?da?a : > > But is there any universal method that works fine in linux and win32? Linux is easy as well! ;-) If your target Linux system has xdg-utils you can use the following command: xdg-email

So. I should use defines {IFDEF ... and two different methods for both OS? I had hopes that exist one universal way to use mailto: ? OK. I do it.
Thanks a lot.

;) Irek -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081210/4827605a/attachment.html

Reply by email

Ireneusz Wyglądała
to Ireneusz Wyglądała

2008/12/10 Ireneusz Wygl?da?a

Show quoted text 7 lines
On Wed, Dec 10, 2008 at 13:48, Graeme Geldenhuys wrote: > 2008/12/10 Ireneusz Wygl?da?a : > > >

By the way.
Is any similar method for opening HTML files without using application name eg. firefox.

;) Irek -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081210/7cd0c333/attachment-0001.html

Reply by email

Ireneusz Wyglądała
to Ireneusz Wyglądała

2008/12/10 Ireneusz Wygl?da?a

Show quoted text 17 lines
2008/12/10 Ireneusz Wygl?da?a > > On Wed, Dec 10, 2008 at 13:48, Graeme Geldenhuys < > > wrote: > >> 2008/12/10 Ireneusz Wygl?da?a : >> > >> > By the way. Is any similar method for opening HTML files without using application name eg. firefox.

OK. I just checked -> xdg-open ;)
Sorry

;) Irek -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081210/6bb5ede4/attachment.html

Reply by email

Graeme Geldenhuys
to Ireneusz Wyglądała: So. I should use defines {IFDEF ... and two different methods for both OS? I had hopes…

2008/12/10 Ireneusz Wygl?da?a :

Show quoted text 5 lines
So. I should use defines {IFDEF ... and two different methods for both OS? I had hopes that exist one universal way to use mailto: ? OK. I do it. Thanks a lot.

What I have done, is to abstract that those calls, so my application doesn't need to contain the IFDEF's. I have one "utilities" unit that contains any IFDEF and *no* other place.

Something like the following

    -------[ MyCoolUtilitiesUnit.pas ]--------------
    uses
       {ifdef windows}
         MyWindowsUtilities,
       {endif}
       {ifdef unix}
          MyUnixUtilities,
       {endif}
       SysUtils;
     functions SendEmai(....): integer;
     begin
       {ifdef windows}
         WindowsSendEmail(...);  //   <---  located in MyWindowsUtilities unit
       {endif}
       {ifdef unix}
          UnixSendEmail(...);  //  <--- located in MyUnixUtilities unit
       {endif}
     end

So now anywhere in your application you can simply include the 'MyCoolUtilitiesUnit' in the uses clause and call SendEmail() - without IFDEF. :-)

One can't always avoid ifdef's but you can limit them to a single unit in your application.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Ireneusz Wyglądała: 2008/12/10 Ireneusz Wygl?da?a OK. I just checked -> xdg-open ;) Sorry ;) Irek…

2008/12/10 Ireneusz Wygl?da?a :

Show quoted text 7 lines
> By the way. > Is any similar method for opening HTML files without using application > name eg. firefox. > OK. I just checked -> xdg-open ;) Sorry

Yes, xdg-open works for many mime types, not just HTML.

eg:
xdg-open URL ---> Uses a web browser
xdg-open PATH ---> Uses you file manager
xdg-open FILE ---> A text editor or email program etc... ....

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Ireneusz Wyglądała: 2008/12/10 Ireneusz Wygl?da?a By the way. Is any similar method for opening HTML files…

2008/12/10 Ireneusz Wygl?da?a :

By the way. Is any similar method for opening HTML files without using application name eg. firefox.

Just thought I would mention. I applied the same abstraction as I described before, but for opening URL's as well. So again, by application simply calls OpenURL(...) no matter the platform it runs on.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Bart
to Ireneusz Wyglądała: 2008/12/10 Ireneusz Wygl?da?a By the way. Is any similar method for opening HTML files…
By the way. Is any similar method for opening HTML files without using application name eg. firefox.

As others pointed out xdg-open will do that.
You might take a look at my BrowserDetection unit, which uses xdg-open if available, or tries some other options if it is not there. AFAICT it should also run under Darwin (MacOSX).
It's at: http://home.tiscali.nl/~knmg0017/software/fpc_laz/browserdetection.tgz

Comments are welcome.

It should be easy to expand this for email use also.

Bart

Reply by email