![]() |
2011-04-27
, 07:20
|
|
Posts: 412 |
Thanked: 480 times |
Joined on Feb 2011
@ Bronx, NY
|
#2
|
![]() |
2011-04-27
, 07:48
|
Posts: 26 |
Thanked: 1 time |
Joined on Oct 2010
|
#3
|
#include <QDesktopServices> void MyClass::slotSendFileViaEmail(const int itemId) { const QString fileName = getFileFromItemId(itemId); // Logic in program checks existence of file somewhere else // and this slot should be called only in case it exists. Q_ASSERT(QFileInfo(fileName).exists()); // Version 1 QDesktopServices::openUrl(QUrl("mailto:?subject=File from our app.&attach=" + fileName)); // Version 2 QDesktopServices::openUrl(QUrl("mailto:?subject=File from our app.&attachment=" + fileName)); }
#include <QMessage> #include <QMessageService> #include <QFileInfo> QTM_USE_NAMESPACE; void MyClass::slotSendFileViaEmail(const int itemId) { const QString fileName = getFileFromItemId(itemId); // Logic in program checks existence of file somewhere else // and this slot should be called only in case it exists. Q_ASSERT(QFileInfo(fileName).exists()); QStringList attachment; attachment.append(fileName); QMessage msg; msg.setType(QMessage::Email); msg.setSubject("File from our app."); msg.setBody("File from our app is included in attachement."); msg.appendAttachments(attachment); QMessageService msgService; // User will fill reciver email, can write additional info, // etc. and finally send. bool success = msgService.compose(msg); if(!success) { // Send info for example via QMessageBox } }
The Following User Says Thank You to Laethnes For This Useful Post: | ||
![]() |
2011-04-29
, 09:10
|
Posts: 26 |
Thanked: 1 time |
Joined on Oct 2010
|
#4
|
I know about possibility write own client connecting to SMTP server, but I would love to avoid it...
Last edited by Laethnes; 2011-04-29 at 09:11.