Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. API Call to find the installed Default Email Client ??

API Call to find the installed Default Email Client ??

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiojsonquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robert Palma Jr
    wrote on last edited by
    #1

    I would like users of my program to be able to launch their currently installed email client from within my program. I would know the proper API call to find the path to the executable for the Email client that is currently installed on a machine. C/C++, Visual Studio 6.0 Many thanks, :) Robert

    R 1 Reply Last reply
    0
    • R Robert Palma Jr

      I would like users of my program to be able to launch their currently installed email client from within my program. I would know the proper API call to find the path to the executable for the Email client that is currently installed on a machine. C/C++, Visual Studio 6.0 Many thanks, :) Robert

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Admitedly a cheesy solution, but it should get the job done. :)

      HINSTANCE hInst = ::ShellExecute
      (NULL, "open",
      "mailto:ravib@ravib.com", // use "mailto:" to open mail
      "", "", SW_SHOW); // client w/o opening a new msg
      ASSERT (hInst > 32);

      /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      R 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Admitedly a cheesy solution, but it should get the job done. :)

        HINSTANCE hInst = ::ShellExecute
        (NULL, "open",
        "mailto:ravib@ravib.com", // use "mailto:" to open mail
        "", "", SW_SHOW); // client w/o opening a new msg
        ASSERT (hInst > 32);

        /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        R Offline
        R Offline
        Robert Palma Jr
        wrote on last edited by
        #3

        Ravi, Thanks for reply. I have used that approach fro text messages. The purpose of this feature is to allow the User of my program to attach a file to an email. I believe that only very small files can be attached with ShellExecute(). MAPI is another way to do it but MAPI is a real mess of DLLs and various users may not have the right version of the MS MAPI DLL on their machine. Also, some email clients like Eudora require the user to specifically turn on MAPI, so using MAPI complicates their lives. If I can find the default email client then I can launch it with the attached file as a command line parameter. Thanks, Robert

        D 1 Reply Last reply
        0
        • R Robert Palma Jr

          Ravi, Thanks for reply. I have used that approach fro text messages. The purpose of this feature is to allow the User of my program to attach a file to an email. I believe that only very small files can be attached with ShellExecute(). MAPI is another way to do it but MAPI is a real mess of DLLs and various users may not have the right version of the MS MAPI DLL on their machine. Also, some email clients like Eudora require the user to specifically turn on MAPI, so using MAPI complicates their lives. If I can find the default email client then I can launch it with the attached file as a command line parameter. Thanks, Robert

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Robert Palma Jr. wrote: I believe that only very small files can be attached with ShellExecute(). ShellExecute() has no idea what you are using the mailto: protocol for. If there is a problem with the size of an attachment, it would be up to the mail client to deal with it. If the target machine already has a mail client configured, then MAPI is the way to go. See here for SMTP and MAPI articles.


          "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

          R 1 Reply Last reply
          0
          • D David Crow

            Robert Palma Jr. wrote: I believe that only very small files can be attached with ShellExecute(). ShellExecute() has no idea what you are using the mailto: protocol for. If there is a problem with the size of an attachment, it would be up to the mail client to deal with it. If the target machine already has a mail client configured, then MAPI is the way to go. See here for SMTP and MAPI articles.


            "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

            R Offline
            R Offline
            Robert Palma Jr
            wrote on last edited by
            #5

            Hi David, Thanks for reply. Lots of good articles on your link! Okay, how would you include an attachemnt in the mailto call?? ::ShellExecute(NULL, "open","mailto:joe@something.com","","",SW_SHOW); Thanks a lot, Robert

            D 1 Reply Last reply
            0
            • R Robert Palma Jr

              Hi David, Thanks for reply. Lots of good articles on your link! Okay, how would you include an attachemnt in the mailto call?? ::ShellExecute(NULL, "open","mailto:joe@something.com","","",SW_SHOW); Thanks a lot, Robert

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Use this format: mailto:joe@something.com?subject=Test&attachment="c:\boot.ini"


              "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

              R 1 Reply Last reply
              0
              • D David Crow

                Use this format: mailto:joe@something.com?subject=Test&attachment="c:\boot.ini"


                "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                R Offline
                R Offline
                Robert Palma Jr
                wrote on last edited by
                #7

                Hi David, Here is what I tried: //Shell execute test //from David mailto:joe@something.com?subject=Test&attachment="c:\boot.ini" sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\misc\a.txt\""); ShellExecute(NULL,"open", buf,"","",SW_SHOWNORMAL); I tried this on NT and Win2K. I tried this on Eudora and Outlook 2003. In all cases, the email client loads the 'to' address and the 'subject', but does not seem to know about the attachment. I have been working on this since May. Back in May Jim Twine kindly told me (in this forum) that he did not think I could do this with ShellExecute and that I would have to use MAPI. I have not had success with MAPI so I have been looking at running the mail client from the command line. Outlook and Eudora seem to do this quite well. I just have to find out 'who' is the client and 'where' (directory) he is. Actually I REALLY don't even want to specify the 'to' address or the 'subject'. I'd like the User to pick the 'to' address from his email-client-addressbook. I would love to hear anymore thoughts on getting ShellExecute to work. It's seems quite simple and elegant and I use it all the time for other executables. All the best, :) Robert

                D 1 Reply Last reply
                0
                • R Robert Palma Jr

                  Hi David, Here is what I tried: //Shell execute test //from David mailto:joe@something.com?subject=Test&attachment="c:\boot.ini" sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\misc\a.txt\""); ShellExecute(NULL,"open", buf,"","",SW_SHOWNORMAL); I tried this on NT and Win2K. I tried this on Eudora and Outlook 2003. In all cases, the email client loads the 'to' address and the 'subject', but does not seem to know about the attachment. I have been working on this since May. Back in May Jim Twine kindly told me (in this forum) that he did not think I could do this with ShellExecute and that I would have to use MAPI. I have not had success with MAPI so I have been looking at running the mail client from the command line. Outlook and Eudora seem to do this quite well. I just have to find out 'who' is the client and 'where' (directory) he is. Actually I REALLY don't even want to specify the 'to' address or the 'subject'. I'd like the User to pick the 'to' address from his email-client-addressbook. I would love to hear anymore thoughts on getting ShellExecute to work. It's seems quite simple and elegant and I use it all the time for other executables. All the best, :) Robert

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Robert Palma Jr. wrote: sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\misc\a.txt\""); Should be:

                  sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\\misc\\a.txt\"");


                  "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                  R 1 Reply Last reply
                  0
                  • D David Crow

                    Robert Palma Jr. wrote: sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\misc\a.txt\""); Should be:

                    sprintf(buf, "mailto:rpalma@mrtel.com?subject=test&attachment=\"c:\\misc\\a.txt\"");


                    "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                    R Offline
                    R Offline
                    Robert Palma Jr
                    wrote on last edited by
                    #9

                    Hi David, Thankyou for your very quick replys :) I fixed my dumb error in formating per your correction - thanks. Eudora still ignores the attachement. Outlook (this is different) says the command line switch is in error. I have had no luck with a command line reference from Eudora (Qualcomm) even though I am a re-registered user with the last 4 months. I will look for a reference on Outlook command line switches, but previous research efforts in this regard were not fruitful. Any other ideas? All the best, Robert

                    D 1 Reply Last reply
                    0
                    • R Robert Palma Jr

                      Hi David, Thankyou for your very quick replys :) I fixed my dumb error in formating per your correction - thanks. Eudora still ignores the attachement. Outlook (this is different) says the command line switch is in error. I have had no luck with a command line reference from Eudora (Qualcomm) even though I am a re-registered user with the last 4 months. I will look for a reference on Outlook command line switches, but previous research efforts in this regard were not fruitful. Any other ideas? All the best, Robert

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      Robert Palma Jr. wrote: Eudora still ignores the attachement. Admittingly, the attachment part may not be standard. You'll have to read the RFC for mailto: to find out. Robert Palma Jr. wrote: Outlook (this is different) says the command line switch is in error. I use Outlook 2000 and it worked for me. Robert Palma Jr. wrote: I will look for a reference on Outlook command line switches, but previous research efforts in this regard were not fruitful. Outlook's command line parameters, if it even has any, has nothing to do with the mailto: protocol. Check out the SMTP and MAPI links I provided earlier. Something else you might try is:

                      char szApp[MAX_PATH];
                      AssocQueryString(..., ".eml", "open", szApp, sizeof(szApp));


                      "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups