Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email with attachment using client's email application

I need my locally-installed, thick-client application (Qt / C++) to generate a ready-to-be-sent email message on the client's machine:

  • This message must contain the contents of a relatively small (15K - 200K) binary file.
  • Many of my users will be disconnected at the time this message is generated, so it is possible the email will need to sit in the outbox until a later time.
  • This application will run on Windows, Mac OS X, and various Linux distros (official support for Ubuntu/Debian and Fedora), and there is no requirement that specific email clients need to be installed.

I have already tried:

  • Opening a mailto: link using QDesktopServices::openUrl() with the attach (or attachment) parameter. But those parameters are not officially part of the protocol, and some clients (notably Outlook) ignore them.
  • Encoding the file using Base64 and adding it as part of the body parameter of a mailto: link. But the length of the mailto link is truncated by some email clients (again, notably Outlook) so this will not work.

Google Picasa achieves this (at least, on Windows; haven't checked other OS's) when you send pictures from within the application. It creates a message with the attachments and some pre-filled text. You can then edit the message and send at your convenience. Any ideas how they are doing this?

like image 280
Dave Mateer Avatar asked Jan 20 '11 20:01

Dave Mateer


People also ask

Can you send an email as an attachment to another email?

Forward an email as an attachment Select the emails that you want. Forward as attachment. In the 'To' field, add recipients. You can also add recipients in the 'Cc' and 'Bcc' fields.

How you can use an email to send a file as an attachment even though it is such a large file?

How to Send Large Files via Email. Store your files in a cloud storage service, like Google Drive, Dropbox, or OneDrive. When you want to send the file, simply share the file with someone, and then notify them via email that you have done so.


1 Answers

You could create an .eml file and open it which should give you the effect you want as long as there is any email client registered in the system to handle files with this extension. I'm sure this is not as universal as the mailto: scheme but if mailto: does not work for you I think this could be the second best option to try.

From http://www.coolutils.com/Formats/EML

Since EML files are created to comply with the industry RFC 822 standard, they can be used with most e-mail clients, servers and applications. Besides the Microsoft Outlook Express, EML files can be opened using most e-mail clients, such as Microsoft Outlook, Microsoft Entourage, Mozilla Thunderbird, Apple Mail, and IncrediMail.

Side note
When I click 'E-mail' in Picasa I get dialog where I can choose which application (Thunderbird or Google Mail) I want to send email with. This means Picasa knows specific email client being used to send email and can use custom method, specific to chosen email client, to send email. This is of course just speculation but it might be that Picasa makes user to choose email client because there's no generic way to do what you ask about.

like image 73
Piotr Dobrogost Avatar answered Oct 18 '22 19:10

Piotr Dobrogost