[Solved] Show Message Box


Based on your code and the fact that you posted your actual credentials on a public forum, I will assume you just want a synchronous solution and want to show a message box after your (blocking) call to MyServer.Send();

wrap your send in a try/catch block:

// The program will attempt to send a message
try
{
    MySever.Send(MyMsg);
    MessageBox.Show("Message sent successfully");
}
catch (Exception ex)
{
    // Whoops there was an error sending the message, better tell the user what happened.
    MessageBox.Show(String.Format("Message Failed To send because: {0}", ex.message);
}

If this is not working, then you will need to add some context to your question, such as any errors or exceptions you are seeing.

The “right” way to do this though would be to do MyServer.SendAsync(MyMsg) and then have a callback listening to the SendCompleted event provided to you by the SMTPClient class:

MSDN Example of Async Mail Send

2

solved Show Message Box