Using Easy Email with the fnSendEzEmail function


There are 3 methods available to send emails using the Easy Email Plug-in. Emails can be sent using:



Note: Before any emails can be successfully sent, the Easy Email Settings must be configured.


This section describes how to use the fnSendEzEmail function to send emails.


The Communication Manager and the Element Message Tab are the easiest ways to use the Easy Email Plug-in to send emails.


This method is provided for the rare occasions when where drag and drop function control is required.  Also, this technique serves as tutorial for creating and using MQL functions.


Background


The MetaTrader platform supports sending emails using a simple built-in function named SendMail.  


Unfortunately, the SendMail function only works with non-secure email servers, and today almost all email providers use secure connections for sending and receiving emails.


In order to establish a secure email connection, additional code must be created to manage an SMTP connection.  SMTP stands for Simple Mail Transfer Protocol and is an internet standard for sending and receiving emails.


The  SMTP connection code resides in a Dynamic Link Library (DLL).  (In this case, the DLL is named ezemail.dll)


For an Expert Advisor to use the functionality of a DLL, the DLL must be described and referenced in the MQL code, and the DLL must reside in the libraries folder of the MetaTrader platform.


VTS automatically copies the DLL to the libraries folder and adds all required MQL code to use the Easy Email functions.




The function fnSendEzEmail is available from the Toolbox under the Common menu.


The fnSendEzEmail  function is an MQL function.


Because fnSendEzEmail is an MQL function, the MQL source code of this function is available from the Toolbox under the Advanced->MQL menu.


The name of the MQL source code function has been changed to fnSendEzEmailMql to create a distinction between the two functions.


When you create an MQL function, the name of the function within the MQL code will be the name of the function on the Advanced->MQL menu.


The name of the MQL Element in which the MQL code was entered can be named any available name, for example MyMql.


The function on the Advanced->MQL menu holds the MQL source code and can be edited at any time.


The function MyMql represents a call to the function on the Advanced->MQL menu.  It does not contain the MQL code, only a call to the underlying function with the parameters set specifically.


For example, the function fnSendEzEmail can be dragged onto to the Drawing Pad, set the To parameter to a work email address and named SendEmailToWork.  


Another copy can be dragged onto the Pad, the To parameter set to a home email address and name SendEmailHome.


More information about MQL function is described here.


The parameters of the  fnSendEzEmail  function are described below.




NOTE: There is no count available to control how many times an email is sent when using the  fnSendEzEmail  function.  Care must be exercised to ensure a large number of emails are not sent.



Name


Data Type

Description

Server

string

The smtp server name of your email provider.  The smtp server name can be found by (1) asking you email provider, or (2) a simple internet search.

UserName

string

This is the email address that you have with your email provider.  (Note: It can also be the To Address that emails are sent to).

Password

string

The password used to connect with the Email Address with your email service provider. NOTE: This password is stored as clear text. Do not use the same password that you use for high security accounts.

Port

integer

The port of your email providers smtp service.  For secure connections, the value is usually 465. The smtp port number can be found by (1) asking you email provider, or (2) a simple internet search.

From

string

The email address that your email will show that it was sent from.  Normally you do not need to set this value when you compose an email within an email program, but this field is required to create a valid email.  The From address can be the same as the To address.

To

string

The email address that your email will be sent to.

Copy

string

Optional email address to copy your email to.

Subject

string

The subject that will appear in the subject line of the email.

Body

string

The body of the email (the text message).

AttachFile

string

The full path of a file to be attached to the email.


Related Topics:
What is VTS
Why use VTS
System Requirements
Installing VTS
Main Menu
Toolbox FUNCTIONS Pane
Everything You Need To Know About VTS
Expert Advisor Facts
Configure
Configure
PLATFORM Function
Custom Indicators
MQL Function
TEXT Element
INPUT Manager
TRADETIME Manager
TRADESIGNAL Manager
COMMUNICATION Manager
OPENTRADE Manager
Message
Logic
Options
MetaTrader Platform Configuration
Compiler
Compiler Flags
Platform
Editor
EA Output Folder
Custom Indicator Folder
Package
Special Functions
fnOpenOrder
fnModifyOrder
fnCloseOrder
init and deinit
Getting Started
MetaTrader Platform
Journal Tab
Experts Tab
Expert Menu
MQL Help
Trade Tab
ECN Brokers
Step 2
Function and Logic Power Plug-in
Logic
Candlestick Plug-in
Candlestick Function Parameters
Candlestick Drawing
Using a Candlestick Function in a Logic Element
Easy Email Plug-in
Configure Easy Email Settings
Using Easy Email from the Communication Manager
Using Easy Email from any Element
Testing the Easy Email Connection
TrendLine Plug-in
Objects on the MetaTrader platform
Manually drawing a trend line
Removing a trend line
Building an Expert Advisor to manage a manually drawn trend line
Building an Expert Advisor to draw and manage a trend line
Grid Plug-in
FX PowerGrid Functions
Grid Main Settings
fnRemoveLines
Using FX PowerGrid
Script & Multi-Platform Plug-in
Building a MetaTrader Script
Using the Multi-Platform Feature
Profit Exits Plug-in
Profit Manager Plug-in
Target
Action
Price Chart
Client-Side Stops Plug-in
Emergency Stops
Using Client-Side Stops
Fibonacci Trader Plug-in
Objects on the MetaTrader Platform
Manually Drawing a Fibonacci Retracement
Removing a Fibonacci Retracement
Building an Expert Advisor to manage a manually drawn Fibonacci retracement
Building an Expert Advisor to draw and manage a Fibonacci retracement
Signal Aggregator Plug-in
Signal Type: Element
Signal Type: MQL
Signal Type: Logic Condition
MQL-Mentor Plug-in
Using the Code Block Feature
Partial-Close Plug-in
Partial-Close Price Chart
EA-Indicator Plug-in
Using the EA-Indicator Plug-in
Custom Indicators in the Toolbox
EA-Indicator Price Chart
EA-Indicator Video
Chart Objects Plug-in
fnDrawHorizontalLine
fnDrawVerticalLine
fnDrawArrow
fnDrawThumb
fnDrawLabel
fnDrawText
fnDrawCheckSign
fnDrawStopSign
Chart Objects on a MetaTrader Price chart
Market Score Plug-in
Adding Symbols
Order History Plug-in
EA Secure Plug-in
EA Secure Configuration
Chart Execute Plug-in
Chart Execute Configuration
Chart Execute on Price Chart
Using Chart Execute
Chart Execute Notes
Money Manager Plug-in
Money Manager Configuration
Money Management Table
Package Plug-in
Pivot Points Plug-in
Using the Pivot Point Plug-in
Pivot Points on a MetaTrader Price Chart
File IO Plug-in
fnFileRead
fnFileWrite
fnDeleteFile
Multi Trade Plug-in
Multi Trade on a MetaTrader Price Chart
Debug Manager Plug-in
Using the Debug Manager Plug-in
Event Manager Plug-in
MQL Event Documentation