From 260c354d6fb8ff33fe7b44e23c7a6aa54960fdaf Mon Sep 17 00:00:00 2001 From: SimplestStudio Date: Wed, 5 Mar 2025 12:23:19 +0200 Subject: [PATCH] refactoring --- win-linux/src/cmailmessage.cpp | 9 +++++---- win-linux/src/cmailmessage.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/win-linux/src/cmailmessage.cpp b/win-linux/src/cmailmessage.cpp index e7eb9a265..64ef2986a 100644 --- a/win-linux/src/cmailmessage.cpp +++ b/win-linux/src/cmailmessage.cpp @@ -124,10 +124,10 @@ CMailMessage &CMailMessage::instance() return inst; } -void CMailMessage::openEML(const std::string &from, const std::string &to, const std::string &subject, const std::string &msg) +void CMailMessage::openEML(const std::string &to, const std::string &subject, const std::string &msg) { std::ostringstream data; - data << "From: " << from << "\n" + data << "From: " << /*from <<*/ "\n" << "To: " << to << "\n" << "Subject: " << subject << "\n" << "Date: " << getFormattedDate() << "\n" @@ -151,8 +151,9 @@ void CMailMessage::openEML(const std::string &from, const std::string &to, const } #ifdef _WIN32 -bool CMailMessage::sendMapiMail(std::string to, std::string name, std::string subject, std::string msg) +bool CMailMessage::sendMailMAPI(std::string to, std::string subject, std::string msg) { + to.insert(0, "SMTP:"); if (HMODULE lib = LoadLibrary(L"mapi32.dll")) { ULONG (WINAPI *_MAPISendMail)(LHANDLE, ULONG_PTR, MapiMessage*, FLAGS, ULONG); *(FARPROC*)&_MAPISendMail = GetProcAddress(lib, "MAPISendMail"); @@ -165,7 +166,7 @@ bool CMailMessage::sendMapiMail(std::string to, std::string name, std::string su MapiRecipDesc recip[1] = { {0} }; recip[0].ulRecipClass = MAPI_TO; recip[0].lpszAddress = &to[0]; - recip[0].lpszName = &name[0]; + recip[0].lpszName = &to[0]; std::string fileName = ""; // Forces HTML attachment to be rendered as email body diff --git a/win-linux/src/cmailmessage.h b/win-linux/src/cmailmessage.h index 48ef48911..4044cb6f4 100644 --- a/win-linux/src/cmailmessage.h +++ b/win-linux/src/cmailmessage.h @@ -43,9 +43,9 @@ public: CMailMessage& operator=(const CMailMessage&) = delete; static CMailMessage& instance(); - void openEML(const std::string &from, const std::string &to, const std::string &subject, const std::string &msg); + void openEML(const std::string &to, const std::string &subject, const std::string &msg); #ifdef _WIN32 - bool sendMapiMail(std::string to, std::string name, std::string subject, std::string msg); + bool sendMailMAPI(std::string to, std::string subject, std::string msg); #endif private: