Commit 3ba22ca2 authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2

share: fix case where no default mail client

Change-Id: I534382c60c5efbf9d6669e4adddc39e4d6f079d9
Tuleap: #411
parent 854c6b44
......@@ -19,6 +19,7 @@
#include "utils.h"
#ifdef Q_OS_WIN
#include <windows.h>
#include <lmcons.h>
#include <shobjidl.h>
#include <shlguid.h>
......@@ -26,6 +27,11 @@
#include <shlwapi.h>
#endif
//Qt
#include <QObject>
#include <QErrorMessage>
bool
Utils::CreateStartupLink()
{
......@@ -165,8 +171,17 @@ void
Utils::InvokeMailto(const QString& subject,
const QString& body,
const QString& attachement) {
auto addr = QString("mailto:?subject=%1&body=%2").arg(subject).arg(body);
if (not attachement.isEmpty())
addr += QString("&attachement=%1").arg(attachement);
ShellExecute(nullptr, L"open", addr.toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL);
#ifdef Q_OS_WIN
HKEY hKey;
LONG lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"mailto", 0, KEY_READ, &hKey);
if (lRes != ERROR_FILE_NOT_FOUND) {
auto addr = QString("mailto:?subject=%1&body=%2").arg(subject).arg(body);
if (not attachement.isEmpty())
addr += QString("&attachement=%1").arg(attachement);
ShellExecute(nullptr, L"open", addr.toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL);
} else {
QErrorMessage errorMessage;
errorMessage.showMessage(QObject::tr("No default mail client found"));
}
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment