鼎元C++期货量化/程序化教程【邮件发送通知(将交易日志及交易信息发送至管理员邮箱功能)及调用方法】
  
- UID
- 2
- 积分
- 2914403
- 威望
- 1407234 布
- 龙e币
- 1507169 刀
- 在线时间
- 13521 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-3-3

|
鼎元C++期货量化/程序化教程【邮件发送通知(将交易日志及交易信息发送至管理员邮箱功能)及调用方法】
项目使用场景:
1、每天盘前将系统登录实盘期货账户情况发送至管理员邮箱,若是无法获得资金及持仓,则在开盘前通知管理员进行维护工作。
2、每当有新的交易产生,将交易的价格,方向,数量信息发送至管理员邮箱。方便管理员进行监控。 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|
|
|
|
|
|
  
- UID
- 2
- 积分
- 2914403
- 威望
- 1407234 布
- 龙e币
- 1507169 刀
- 在线时间
- 13521 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-3-3

|
|
|
|
|
|
|
  
- UID
- 2
- 积分
- 2914403
- 威望
- 1407234 布
- 龙e币
- 1507169 刀
- 在线时间
- 13521 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-3-3

|
今天存档一个邮件打开电脑客户端功能,不过不能自动发邮件,要人工点一下才行。- #include <windows.h>
- #include <string>
- #include <iostream>
- // Helper function to convert std::string to std::wstring
- std::wstring stringToWString(const std::string& str) {
- return std::wstring(str.begin(), str.end());
- }
- void sendEmail(const std::string& recipient, const std::string& subject, const std::string& body) {
- std::string mailto = "mailto:" + recipient + "?subject=" + subject + "&body=" + body;
- // 替换空格为 %20
- for (auto& c : mailto) {
- if (c == ' ') {
- c = '%20';
- }
- }
- // 转换为宽字符串
- std::wstring mailtoW = stringToWString(mailto);
- // 调用ShellExecuteW
- HINSTANCE result = ShellExecuteW(
- NULL, // 父窗口句柄
- L"open", // 操作,宽字符
- mailtoW.c_str(), // URL,宽字符
- NULL, // 参数
- NULL, // 工作目录
- SW_SHOWNORMAL // 显示窗口
- );
- if ((INT_PTR)result <= 32) {
- std::cerr << "Failed to open email client. Error code: " << (INT_PTR)result << std::endl;
- }
- else {
- std::cout << "Email client opened successfully!" << std::endl;
- }
- }
- int main() {
- std::string recipient = "邮箱地址";
- std::string subject = "测试邮件";
- std::string body = "这是一封测试邮件This is a test email.";
- sendEmail(recipient, subject, body);
- return 0;
- }
复制代码 |
|
|
|
|
|
|
  
- UID
- 2
- 积分
- 2914403
- 威望
- 1407234 布
- 龙e币
- 1507169 刀
- 在线时间
- 13521 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-3-3

|
|
|
|
|
|
|