Sending Email with carriage return in MT4

 
Hi there,

I am trying to send an email from MT4 in this format but am unable to get it to work

<Header>
ProviderName=CTSFOREX
SendFrom=tronghoang@shaw.ca
SignalSubject= EUR
NumberOfSignals=1
</Header>
<Signal>
SystemName=Forex
SubsystemName=Oneway
Command=Open
Order SubCommand=Market
BuySell=Buy
Currency=
Rate=1.4073
StopLoss=
TakeProfit=
NumPositions=1
</Signal>

I have tried \n, \cr, \lf and nothing seems to work. I would get the email without the carriage return.

<Header>ProviderName=CTSFOREX SendFrom=tronghoang@shaw.ca
SignalSubject= EUR NumberOfSignals=1 </Header><Signal> SystemName=Forex
SubsystemName=Oneway Command=OpenOrder SubCommand=Market BuySell=Buy Currency=
Rate=1.4073 StopLoss= TakeProfit= NumPositions=1 </Signal>

Attached is the email script written in MT4. Can someone tell me what I am doing wrong?

Trong


 


//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   SendsMail("OpenOrder","Market","Buy",AccountCurrency(),DoubleToStr(Ask,4),"","","1");
//----
   return(0);
  }
//+------------------------------------------------------------------+
void SendsMail(string command, string subCommand, string buySell,string currency, string rate, string stopLoss, string takeProfit, string numPositions){
   string subject="{TradencyAPI}";
   string header="<Header>\n"+
                     "ProviderName=CTSFOREX \n"+
                     "SendFrom=tronghoang@shaw.ca \n"+
                     "SignalSubject= EUR \n"+
                     "NumberOfSignals=1 \n"+
                 "</Header>\n";
   string body="<Signal> \n"+
                  "SystemName=Forex \n"+
                  "SubsystemName=Oneway \n"+
                  "Command="     +command     +" \n"+
                  "SubCommand="  +subCommand  +" \n"+
                  "BuySell="     +buySell     +" \n"+
                  "Currency="    +currency    +" \n"+
                  "Rate="        +rate        +" \n"+     
                  "StopLoss="    +stopLoss    +" \n"+
                  "TakeProfit="  +takeProfit  +" \n"+
                  "NumPositions="+numPositions+" \n"+
               "</Signal>";
   SendMail(subject,header+body);
   Comment(header+body);
}





 
Hmm... it worked for me, as posted above, except I replaced all the variables in the body with a string variable set to "dummy"

Here is the mail received in Outlook

<Header>
ProviderName=CTSFOREX
SendFrom=tronghoang@shaw.ca
SignalSubject= EUR
NumberOfSignals=1
</Header>
<Signal>
SystemName=Forex
SubsystemName=Oneway
Command=dummy
SubCommand=dummy
BuySell=dummy
Currency=dummy
Rate=dummy
StopLoss=dummy
TakeProfit=dummy
NumPositions=dummy
</Signal>
 

Hmm... it worked for me, as posted above, except I replaced all the variables in the body with a string variable set to "dummy"

Here is the mail received in Outlook

<Header>
ProviderName=CTSFOREX
SendFrom=tronghoang@shaw.ca
SignalSubject= EUR
NumberOfSignals=1
</Header>
<Signal>
SystemName=Forex
SubsystemName=Oneway
Command=dummy
SubCommand=dummy
BuySell=dummy
Currency=dummy
Rate=dummy
StopLoss=dummy
TakeProfit=dummy
NumPositions=dummy
</Signal>



Thanks for looking at my problem. Any particular reason on why you replace the variable strings into dummy? Can I ask which SMTP server did you use? Can I register for an email account there? I am very suspicious about the SMTP server causing this problem because we are running off the same script; hence, why the different results?
 
I don't have values for your variable so just used a filler
The mail server is on my PC, "Mercury Mail"

Maybe the problem is in your mail CLIENT

send one to me.... ThisWontWorkLater at spambucket.homeip.net
 
No good.

-----Original Message-----
From: Trong Hoang [mailto:tronghoang@xxxxxxx]
Sent: Friday, September 28, 2007 01:34
To: Ocean
Subject: {TradencyAPI}


<Header>ProviderName=CTSFOREX SendFrom=tronghoang@shaw.ca SignalSubject= EUR NumberOfSignals=1 </Header><Signal> SystemName=Forex SubsystemName=Oneway Command=OpenOrder SubCommand=Market BuySell=Buy Currency=USD Rate=1.4164 StopLoss= TakeProfit= NumPosi tions=1 </Signal>
 
use "\r\n" instead of "\n"
 
Does the text in the Comment work correctly?

That text is good here.
 
use "\r\n" instead of "\n"


Slawa, it works great and thank you.


Phy, many thanks for helping out. BTW, how difficult is it to set up a email server on my pc i.e "mercury mail"
 
Pegasus is email client (no need)
Mercury is the post office

http://www.pmail.com/


http://www.pmail.com/v441.htm
http://www.pmail.com/downloads_maine_t.htm

install Mercury/32 Mail Transport System for Win32 and NetWare Systems v4.52
ftp://ftp.usm.maine.edu/pegasus/mercury32/m32-452.exe

Install MercuryS, P, and C modules
for SMTP Server, SMTP Client, and POP3 Server
Do not install "netware" part