How can I send email

 

Hi all 

How can I send email to an email address in MQL5?

 
MEHMET FATIH BARUT:

Hi all 

How can I send email to an email address in MQL5?

MQL5 Function: SendMail

Note

Sending can be prohibited in settings, email address can be omitted as well. For the error information call GetLastError().

SendMail() function does not work in the Strategy Tester.


MetaTrader 5 Setting: Email — email parameters for sending messages straight from the platform;

Mailbox is configured on this tab. These settings will be then used to send message by the Expert Advisor command or by a triggered alert.

Configure email notifications on the Email tab

Documentation on MQL5: Network Functions / SendMail
Documentation on MQL5: Network Functions / SendMail
  • www.mql5.com
Network Functions / SendMail - Reference on algorithmic/automated trading language for MetaTrader 5
 

Example: the adviser at the time of the birth of a new bar sends an email with the text "I'm alive!"

//+------------------------------------------------------------------+
//|                                                   Send email.mq5 | |
//+------------------------------------------------------------------+
#property version   "1.00"
//---
datetime m_prev_bars                = 0;        // "0" -> D'1970.01.01 00:00';
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(Symbol(),Period(),0);
   if(time_0==m_prev_bars)
      return;
   m_prev_bars=time_0;
//--- Send Mail
   SendMail(__FILE__,"Symbol: "+Symbol()+", I'm alive!");
  }
//+------------------------------------------------------------------+
Files:
 
Great! thank you.
 
btw what is the gmail settings for mt5?
 
emails when my account takes a trade
emails when my account takes a trade
  • 2017.03.01
  • www.mql5.com
Hello guys, ‌Is it possible that MT5 send me an email to my private emailadres, when my account makes a trade...
 
thanks a lot
 
Can you get your clients email so I can give updates
Reason: