SendMail Help / Tips

I have a strategy that I am looking to get email alerts for trades. I have setup both a Gmail and Outlook account for testing. When sending test emails, I have found that it seems very inconsistent and works most of the time but not all the time.

Here is my code

protected override void OnBarUpdate()
{

if (Position.MarketPosition == MarketPosition.Long && XXXXX)
{
ExitLong();

if(EmailTextAlert)
 {
 SendMail("myemailaddress", "Trade Alert", "EXIT LONG " +    TradeInstrument + "  " + Time[0].Date);
 }

I have both a Gmail and outlook account connection setup in the share services. As stated, I can get test emails most of the time, but not consistently and I have not been able to get any when testing the strategy realtime for MES using CME group datafeed through NT Brokerage. I’m looking for some help or any suggestions to get this to work.

Thanks,
Ray

Bob,

I will give that a try. I was using this a few years ago, and it seemed to work pretty well. From what I remember I was using very similar if not the same code. But it very well could be something in my code.

Has anyone else had success with using the email alerts on a consistent basis recently? I’m trying to figure out if this is worth the time considering its seems to be very inconsistent for me.

Thanks,
Ray