Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sending email attachment via default email client
QtWS25 Last Chance

Sending email attachment via default email client

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 3.3k Views
  • 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.
  • S Offline
    S Offline
    samdol
    wrote on 15 Nov 2017, 09:01 last edited by samdol
    #1

    Hi,
    Using QDesktopServices we could send email via windows default email client
    such as Thunderbird.

    QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
    

    But thunderbird ignores file attachment. Is there any platform independent
    method to send attach file via default email client? or at least working
    method for windows? Some suggestion from web is to use mapi.h. but it seems
    not working well with mingw compiler.

    J V 3 Replies Last reply 15 Nov 2017, 09:04
    0
    • S samdol
      15 Nov 2017, 09:01

      Hi,
      Using QDesktopServices we could send email via windows default email client
      such as Thunderbird.

      QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
      

      But thunderbird ignores file attachment. Is there any platform independent
      method to send attach file via default email client? or at least working
      method for windows? Some suggestion from web is to use mapi.h. but it seems
      not working well with mingw compiler.

      J Offline
      J Offline
      JonB
      wrote on 15 Nov 2017, 09:04 last edited by JonB
      #2

      @samdol
      Not sure exactly what you want by "default email client". Probably no gurarantee that any such will accept attachments.

      If you go down the route of external library, unless you need facilities of MAPI I would recommend using SMTP (SMTP does do attachments).

      I believe I also saw the other day that someone has implemented a command-line SMTP client to do mailing, if that does attachments it could be a simple way avoiding coding --- but then your target machines would need it/you'd have to supply with your app.

      S 1 Reply Last reply 15 Nov 2017, 11:29
      1
      • S samdol
        15 Nov 2017, 09:01

        Hi,
        Using QDesktopServices we could send email via windows default email client
        such as Thunderbird.

        QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
        

        But thunderbird ignores file attachment. Is there any platform independent
        method to send attach file via default email client? or at least working
        method for windows? Some suggestion from web is to use mapi.h. but it seems
        not working well with mingw compiler.

        V Offline
        V Offline
        VRonin
        wrote on 15 Nov 2017, 09:11 last edited by
        #3

        @samdol said in Sending email attachment via default email client:

        Is there any platform independent method to send attach file via default email client?

        Short answer: no, because it would represent a security vulnerability so most modern clients explicitly prevent that to be possible

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • S samdol
          15 Nov 2017, 09:01

          Hi,
          Using QDesktopServices we could send email via windows default email client
          such as Thunderbird.

          QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
          

          But thunderbird ignores file attachment. Is there any platform independent
          method to send attach file via default email client? or at least working
          method for windows? Some suggestion from web is to use mapi.h. but it seems
          not working well with mingw compiler.

          J Offline
          J Offline
          JonB
          wrote on 15 Nov 2017, 09:17 last edited by JonB
          #4

          @samdol said in Sending email attachment via default email client:

          Hi,
          Using QDesktopServices we could send email via windows default email client
          such as Thunderbird.

          QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
          

          But thunderbird ignores file attachment.

          Oh, hang on, it may just be the way you're specifying your attachment command-line. See https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options:

          attachment='file:///c:/test.txt'

          Try that (assuming "command-line options" applies when Url, I don't know, worth a try)?

          S 1 Reply Last reply 15 Nov 2017, 11:18
          0
          • J JonB
            15 Nov 2017, 09:17

            @samdol said in Sending email attachment via default email client:

            Hi,
            Using QDesktopServices we could send email via windows default email client
            such as Thunderbird.

            QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attach=C:/myfolder/file.pdf") );
            

            But thunderbird ignores file attachment.

            Oh, hang on, it may just be the way you're specifying your attachment command-line. See https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options:

            attachment='file:///c:/test.txt'

            Try that (assuming "command-line options" applies when Url, I don't know, worth a try)?

            S Offline
            S Offline
            samdol
            wrote on 15 Nov 2017, 11:18 last edited by samdol
            #5

            @JNBarchan
            I saw some windows app launches thunderbird with file attachment. So it is possible to do in windows. They may uses MAPI. As you suggested I may implement SMTP client on my program, but I don't want to encourage people enter their password in my program. Besides, people have to enter their password every time they use the program.

            attachment='file:///c:/test.txt'
            Unfortunately, this did not make change. It launches my default email client, thunderbird, and it passes subject and body, but thunderbird ignores attachment.

            V 1 Reply Last reply 15 Nov 2017, 11:52
            0
            • J JonB
              15 Nov 2017, 09:04

              @samdol
              Not sure exactly what you want by "default email client". Probably no gurarantee that any such will accept attachments.

              If you go down the route of external library, unless you need facilities of MAPI I would recommend using SMTP (SMTP does do attachments).

              I believe I also saw the other day that someone has implemented a command-line SMTP client to do mailing, if that does attachments it could be a simple way avoiding coding --- but then your target machines would need it/you'd have to supply with your app.

              S Offline
              S Offline
              samdol
              wrote on 15 Nov 2017, 11:29 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • S samdol
                15 Nov 2017, 11:18

                @JNBarchan
                I saw some windows app launches thunderbird with file attachment. So it is possible to do in windows. They may uses MAPI. As you suggested I may implement SMTP client on my program, but I don't want to encourage people enter their password in my program. Besides, people have to enter their password every time they use the program.

                attachment='file:///c:/test.txt'
                Unfortunately, this did not make change. It launches my default email client, thunderbird, and it passes subject and body, but thunderbird ignores attachment.

                V Offline
                V Offline
                VRonin
                wrote on 15 Nov 2017, 11:52 last edited by VRonin
                #7

                Is there any platform independent method to send attach file via default email client?

                I saw some windows app launches thunderbird with file attachment.

                Again, some clients support the attach= syntax but you can't guarantee it works on every platform and email client as it's not part of the standard.
                MS Outlook 2007 or newer, for example, explicitly prevents it.

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                2

                1/7

                15 Nov 2017, 09:01

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved