Results 1 to 9 of 9

Thread: Handle :mailto links

  1. #1
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Handle :mailto links

    Hi,

    I would like to write a very simple application that would handle/hook the clics on :mailto links under Windows, and open the FreFox navigator instead of the default mail client.

    The links I want to handle are thoses of other applications, and if possible thoses of the web navigator. I know how to call Firefox (QDesktop or QProcess) but I've no idea about detecting a clic on a :mailto link, no more than how to cancel the default mail client opening.

    Is it possible to do it with Qt ?

    Thanks for your help

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Handle :mailto links

    J-P Nurmi

  3. #3
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Handle :mailto links

    I don't understand how it could help me .

    I think I didn't explained my goal correctly .
    I want to write a small application that would run all the day during (launched at Windows startup). This application would detect when the computer user clic on a :mailto link of other application (Microsoft Word, Open Office, for example) and prevent the default mail client from opening. Instead, it would launch the web navigator with a given URL.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Handle :mailto links

    Oh, sorry for misunderstanding. QDesktopServices indeed works only in your application. This does not sound like a job for Qt anyway.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Handle :mailto links

    Ok JPN, thanks anyway

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Handle :mailto links

    I think all you need is to register your application as the default mail handler in your system. Then all requests for sending mails will be passed to your application.

  7. #7
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Handle :mailto links

    Yes, this is exactly what I've done

    The problem is that I need to pass arguments to my application (title of the mail, for example, and destinary). I've seen that the Windows Registry can pass mailto arguments, and I'm trying to deal with...

    In reality I've another strange problem : in order to test the arguments and to see if they are passed to my application, in write them in a file.
    Here is my main :

    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include <iostream>
    4.  
    5. #include <QString>
    6. #include <fstream>
    7. #include <iostream>
    8. using namespace std;
    9.  
    10. #include "Mailto_Handler.h"
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QApplication app(argc, argv);
    15.  
    16. //Mailto_Handler * mon_gestionnaire = new Mailto_Handler();
    17.  
    18. QString argument_1 = argv[1];
    19. QString argument_2 = argv[2];
    20. QString argument_3 = argv[3];
    21. QString argument_4 = argv[4];
    22. QString argument_5 = argv[5];
    23.  
    24. ofstream mon_fichier ("parametres.txt");
    25. if (mon_fichier.is_open())
    26. {
    27. mon_fichier << "Argument 1 : \t" << argument_1.toStdString() << endl;
    28. mon_fichier << "Argument 2 : \t" << argument_2.toStdString() << endl;
    29. mon_fichier << "Argument 3 : \t" << argument_3.toStdString() << endl;
    30. mon_fichier << "Argument 4 : \t" << argument_4.toStdString() << endl;
    31. mon_fichier << "Argument 5 : \t" << argument_5.toStdString() << endl;
    32.  
    33. mon_fichier.close();
    34. }
    35.  
    36. //exit(0);
    37. return app.exec();
    38. }
    To copy to clipboard, switch view to plain text mode 

    This works well if I call my application :
    - by double-clicking it
    - by calling it from a Batch file
    - by calling it from MSYS command line

    But if I call it from the registry, when I use a mailto link, I've a problem : the file is not written. The application is launched, that is sure : I see it in the task monitor. But the file is n't written...

    Have you got an idea ?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Handle :mailto links

    Use an absolute path to the file.

  9. #9
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Handle :mailto links

    Oups yes...

    Thanks Wysota

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.