Actually, the IsConnected
or IsAuthenticated
property have only informative purpose, they do not actively check the connection.
So you would need your own method to check whether the connection is still alive. The best is to send a NOOP command to the server and get a response.
In fact, even with this approach it can happen, that your method returns 'true' and in the next moment the socket could be potentially closed.
Due to the nature of TCP/IP, the socket can be closed by either the SMTP server, or by some network device along the way without the client being notified, so be prepared for the InvalidOperationException even though you actively check the connection state before the Smtp.Send method. Although this would be really really small probability.