Notifications.SendEmail errors

Created at 09 Oct 2019, 12:34
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
WI

wilson347

Joined 31.07.2019

Notifications.SendEmail errors
09 Oct 2019, 12:34


Hi

I am sending out emails successfully from a GMail account using the standard cAlgo API call to 'Notifications.SendEmail()', so I know the email and everything is set up correctly and my code is correct too. The code is being called from within OnTick().

My problem is that out of the 100 or so emails I have sent, 3 of them have failed (according to the console outputs shown below). Two of the errors are Timeout errors and the other is some sort of 'SmtpException'.

 

1 - 08/10/2019 18:00:14.764 | Failed to send email "GBPJPY, TIMEFRAME: HOUR4, opentime: 08/10/2019 14:00:00, TweezerBottom*BullishHarami*Bullish*". Timeout

2 - 08/10/2019 21:00:02.469 | Failed to send email "AUDCAD, TIMEFRAME: HOUR, opentime: 08/10/2019 20:00:00, TweezerBottom*Bullish*". System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was:     at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.End(IAsyncResult result)    at System.Net.Mail.SmtpTransport.EndGetConnection(IAsyncResult result)    at System.Net.Mail.SmtpClient.ConnectCallback(IAsyncResult result)

3 - 08/10/2019 18:00:15.092 | Failed to send email "AUDCAD, TIMEFRAME: HOUR, opentime: 08/10/2019 17:00:00, candle-stick(s): *SpecialBar*Bullish*". Timeout

 

How can I catch/prevent/detect these failures, in order to re-send the emails, as the return type from Notifications.SendEmail() is void?

Thank you.

 

 

 


@wilson347
Replies

PanagiotisCharalampous
09 Oct 2019, 12:48

Hi davewilson347,

If you are always getting an exception in these cases, you can always use a try catch statement to handle them.

Best Regards,

Panagiotis


@PanagiotisCharalampous

wilson347
09 Oct 2019, 13:46 ( Updated at: 21 Dec 2023, 09:21 )

Thanks for your reply.

I will give it a go:

 


@wilson347