Download MetaTrader 5

Libraries: SendAdvancedEmail

To add comments, please log in or register
No PC at hand? Communicate with friends using your mobile phone!
Automated-Trading
Admin
99873
Automated-Trading 2014.08.01 15:02 

SendAdvancedEmail:

SendAdvancedEmail function for Metatrader 4 and 5 with HTML mailbody support.

My goal was to have a nice and easy email notification. MQL[45] did not suit me, so I decided to code this in C#. Basically I pass every variable from MQL[45] to this DLL. That is all. You can find the DLL in the ZIP Archive.

This DLL has only one function shown below:

#import "SendAdvancedEmail.dll"
   void SendAdvancedEmail(string MailFrom, string MailFromName, string MailTo, string MailCC, string MailSubject, string MailBodyContent, 
                          string MailBodyTemplate, string MailPriority, string MailAttachmentPath, string MailAttachmentName, string SMTPServer, 
                          int SMTPPort, bool SMTPEnableSSL, int SMTPTimeout, string SMTPUsername, string SMTPPassword);
#import

Author: Gorkhaan

Marcos Silva
359
Marcos Silva 2014.11.26 04:35  

Hi,

Im trying to run the indicator with no success on windows 7 + MT4 v745 the error im getting is:

2014.11.25 22:31:51.482 Unhandled exception 0xE0434352

What could be the cause, i have checked all the file permissions and made sure every file was in place, still nothing...

 

Any clues?

Thank You 

Gorkhaan
254
Gorkhaan 2014.12.11 23:01  
investguy:

Hi,

Im trying to run the indicator with no success on windows 7 + MT4 v745 the error im getting is:

2014.11.25 22:31:51.482 Unhandled exception 0xE0434352

What could be the cause, i have checked all the file permissions and made sure every file was in place, still nothing...

 

Any clues?

Thank You 

Hi,

 Thanks for the comment. Yeah recently I started to experience this error too.

I will look into it around January. You guys if you are interested should try to recompile the DLL. I used C#. I will write a howto about that too.

I created something similar but fully MQL4 integrated. Only it has less functionality, it cannot send attachments, yet.

 Screenshots about it here: http://ocsovszki-dorian.blogspot.co.uk/2014/12/simplemailnotification-indicator-for.html

//+------------------------------------------------------------------+
//|                                       SimpleMailNotification.mq4 |
//|                                 Copyright 2014, Dorian Ocsovszki |
//|                           http://ocsovszki-dorian.blogspot.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Dorian Ocsovszki"
#property link      "http://ocsovszki-dorian.blogspot.co.uk"
#property version   "1.00"
#property strict
#property indicator_chart_window


extern bool NotifyEnabled = true;                                                 //Notification Enabled
extern bool ForceNotifyWeekly = true;                                             //Force Notify Weekly
extern ENUM_DAY_OF_WEEK NotifyWeeklyDay = MONDAY;                                 //Notify on this day weekly
extern int NotifyProfitPercent = 300;                                             //Notify on x% ((Balance/Deposit) * 100)
extern int NotifyOnHour = 0;                                                      //Notify every day this given hour: HH:MM:00
extern int NotifyOnMinute = 0;                                                    //Notify every day this given minute: HH:MM:00
extern string NotifyEmailSubject = "[My EA] EURUSD - 300% profit reached";        //Email Subject
extern string NotfiyStrategyName = "MyEA";                                        //Strategy Name


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

if (NotifyEnabled) {
   if ( ((AccountProfit()/AccountDeposits())*100) > NotifyProfitPercent || (ForceNotifyWeekly && DayOfWeek() == NotifyWeeklyDay)) {
      if ( (HourOfDay() == NotifyOnHour) && (Minute() == NotifyOnMinute) && (Seconds() == 0) ) {


string MailHTMLBody = "<html>"
"<head>\n"
        "<title></title>\n"
"</head>\n"
"<body>\n"
"<h3>Mail Notification and Account Report</h3>\n"

"<table align=\"left\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width: 500px;\">\n"
        "<thead>\n"
                "<tr>\n"
                        "<th scope=\"col\">Attribute</th>\n"
                        "<th scope=\"col\">Value</th>\n"
                "</tr>\n"
        "</thead>\n"
        "<tbody>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">Strategy</td>\n"
                        "<td style=\"text-align: center;\">" + NotfiyStrategyName + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountBalance</td>\n"
                        "<td style=\"text-align: center;\"><strong>" + DoubleToString(AccountBalance(),2) + " " + AccountCurrency() + "</strong></td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountEquity</td>\n"
                        "<td style=\"text-align: center;\">" + DoubleToString(AccountEquity(),2) + " " + AccountCurrency() + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">Profit</td>\n"
                        "<td style=\"text-align: center;\"><strong>" + DoubleToString(AccountProfit(),2) + " " +  AccountCurrency() + "</strong></td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">Profit (Profit/Deposit)*100</td>\n"
                        "<td style=\"text-align: center;\"><strong>" + DoubleToString((AccountProfit()/AccountDeposits())*100,2) + "%</strong></td>\n"
                "</tr>\n"               
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountNumber</td>\n"
                        "<td style=\"text-align: center;\">" + IntegerToString(AccountNumber()) + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountCompany</td>\n"
                        "<td style=\"text-align: center;\">" + AccountCompany() + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountCredit</td>\n"
                        "<td style=\"text-align: center;\">" + DoubleToString(AccountCredit(),2) + " " + AccountCurrency() + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountServer</td>\n"
                        "<td style=\"text-align: center;\">" + AccountServer() + "</td>\n"
                "</tr>\n"
                "<tr>\n"
                        "<td style=\"text-align: center;\">AccountLeverage</td>\n"
                        "<td style=\"text-align: center;\">" + IntegerToString(AccountLeverage()) + "</td>\n"
                "</tr>\n"
        "</tbody>\n"
"</table>\n"
"</body>\n"
"</html>";



      SendMail(NotifyEmailSubject,MailHTMLBody);

         
      //Hour and Minute filter
      }
   // Trigger OR ForceNotifyWeekly
   }
//NotifyEnabled
}


//--- return value of prev_calculated for next call
   return(rates_total);
  }
  

int HourOfDay()
{
   MqlDateTime tm;
   TimeCurrent(tm);
   return(tm.hour);
}  


double AccountDeposits() {
   double total=0; 
   for (int i=0; i<OrdersHistoryTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if(OrderType()>5) {
            total+=OrderProfit(); 
         }
      }     
   }  
   return(total); 
}

//+------------------------------------------------------------------+

 

Regards,

Gorkhaan 

To add comments, please log in or register