SendMail

在Mailbox建立的窗口中发送指定地址邮件。

bool  SendMail(
   string  subject,       // 标题
   string  some_text      // email 文本
   );

参量

subject

[in]  邮件标题

some_text

[in]  邮件主题

返回值

如果邮件发送到派送队列则true,否则是false

注释

发送在设置中能被禁止,邮件地址可能未标明,查看错误信息调用 GetLastError()

SendMail() 函数在策略测试中不工作。

示例:

//+------------------------------------------------------------------+
//|                                                     SendMail.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com
#property version     "1.00"
 
#define   SUBJECT   "Test SendMail"
#define   TEXT      "Text for SendMail() function"
//+------------------------------------------------------------------+
//| 脚本程序起始函数                                                   |
//+------------------------------------------------------------------+
void OnStart(void)
  {
//--- 检查从终端中发送电子邮件的许可
   if(!TerminalInfoInteger(TERMINAL_EMAIL_ENABLED))
     {
      Print("Error. The client terminal does not have permission to send email messages");
      return;
     }
//--- 发送邮件
   ResetLastError();
   if(!SendMail(SUBJECTTEXT))
      Print("SendMail() failed. Error ",GetLastError());
  }