Notifications.SendEmail errors
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.
Replies
wilson347
09 Oct 2019, 13:46
( Updated at: 21 Dec 2023, 09:21 )
Thanks for your reply.
I will give it a go:
@wilson347
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