I have an application which is required to send a formatted message and an address to an email client (e.g. Lotus Notes, Outlook, etc. - preferably the former). The client should then mail that message in the background without any intervention (i.e. no one should have to press on send in the client).
I have the message, I have the address and I know how to pick a default email client.
How do I send the preformatted message and address (I'm guessing some MAIL:TO) and have the client send the message automatically?
The application is in C++ and Qt. I'll probably require some API of the client to be called. Do they expose these?
preguntado el 24 de agosto de 12 a las 07:08
This is somewhat platform dependent, and can be handled in one of two
ways: there is a mail server process, to which you connect (using a
socket); or, you pipe the output to a mail client (
under Unix). Piping to the mail client is usually simpler, but I'm not
sure Windows machines have one readily available. (You say you have a
default email client. In what form? If it's a URL, you'll need to use
the socket; if it's the name of a local program, the pipe.)
In both cases, you'll probably want to create a
streambuf to handle
the output, in order to use all of the formatting possibilities of
If you want to do it in background, the surest way is to create a
separate process: write the data to a file, then use
system to execute
the mail client and delete the file when finished (a small batch script).
Alternatively, you can do it in a separate thread, if you're sure that
your process will not be killed before the mail has been sent.