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
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.
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.
Re: How to get default email client to open on clicking 'email' button
Code:
slist+=getenv("BROWSER");
slist+="mailto:someaddr@somehost";
//...
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.
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).
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.
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.