Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

File attachment by QDesktopServices::openUrl



  • Hi,

    I tried to call my email client to attach a picture file by

    QString filePath ="c:/myf/aft.jpg"
    QDesktopServices::openUrl(QUrl("mailto:?subject=test&body=test&attachment;="
    + filePath));
    

    It calls my mail client program, but it did not attached the file.
    I tried both windows and linux. Is this a bug or do I have to do something else?



  • @samdol

    iirc mailto: does not allow this by definition.



  • Only a minority of clients allow attachments via a mailto: link as it's a potential security vulnerability. You have to rely on the client's own API to include attachments to email and there is nothing Qt can do about it


Log in to reply