Results 1 to 8 of 8

Thread: How to get default email client to open on clicking 'email' button

  1. #1
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Smile How to get default email client to open on clicking 'email' button

    Hi all,
    am working on an application created using Qt 3.3(on linux).
    I need to do this--when I click on 'email' pushbutton,the default email client in the system should open up.(by the way,what's the default email client in linux,am not familiar with linux)
    How to do it?I read that from Qt 4.2 onwards there's the Qdesktopservices class which can help.But in Qt 3.3,I guess I will have to use Qprocess.
    Please guide me on how to implement it.
    Thank you for your time.
    Avi

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get default email client to open on clicking 'email' button

    There is no default email client in Linux. You can open a default browser (which should be under the BROWSER environment variable) and point it to the mailto: protocol - it should try to open the default email client set in your system then.

  3. The following user says thank you to wysota for this useful post:

    rishiraj (2nd January 2009)

  4. #3
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to get default email client to open on clicking 'email' button

    Hi,
    sounds quite complicated(atleast for me)

    Can you give me some sample code.That would really help.
    Thank you.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get default email client to open on clicking 'email' button

    Qt Code:
    1. slist+=getenv("BROWSER");
    2. slist+="mailto:someaddr@somehost";
    3. QProcess *proc = new QProcess(slist, this);
    4. //...
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to get default email client to open on clicking 'email' button

    Hi again,
    Tried implementing the code as follows.Please let me know if I made any mistakess.
    QStringList slist;
    slist +=getenv("BROWSER");
    slist +="mailto:abc123@yahoo.com";
    QProcess *proc=new QProcess(slist,this);
    if(!proc->start())
    {
    QMessageBox::critical(0,"fatal error","can't open default email client");
    exit(-1);
    }
    When I click on 'email' I get the message 'Can't open default.....".Does that mean that there's no email client installed in my system.I did a search on the system and came across something like an email client called 'Evolution' but,I don't think anyone's used it before or created a user account.......Is it possible to get some site like 'Hotmail' or yahoo to open instead of the default email client?
    Please advice.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get default email client to open on clicking 'email' button

    It means the process didn't start but reasons for that may vary. Check what getenv("BROWSER") returns, maybe it is not set on a particular system.

    You can open any site you want by providing a different address than mailto:something (like http://www.yourmailsiteaddress.com). But this will only work if the default browser is set (using the $BROWSER env variable).

  8. #7
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to get default email client to open on clicking 'email' button

    Hi,
    used a QMessageBox to get the value of getenv.It shows a blank.
    Any suggestions on what else I could try?
    Also,thanks for being patient and replying to my queries.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get default email client to open on clicking 'email' button

    What happens if you write env|grep BROWSER in a terminal?

    If BROWSER is empty then you need to ask the user to set his email client in the preferences of the application.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.