private void SendMessage(AbstractMailMessage msg, SendCompletedEventHandler onSendCallBack) { // Connecting to the server and configuring it using (var client = new MimeMailer()) { client.Host = _host; client.Port = _port; ((SmtpSocketClient)client).SslType = _ssl; if (String.IsNullOrEmpty(_userName)) { client.AuthenticationMode = AuthenticationType.UseDefualtCridentials; } else { client.Password = _passWord; // Provide your credentials client.User = _userName; } client.SslType = _implictSsl; // Use SendAsync to send the message asynchronously // client.Send(msg); client.SendCompleted += onSendCallBack; // The userState can be any object that allows your callback // method to identify this send operation. // For this example, the userToken is a string constant. client.SendMailAsync(msg); } }
/// <summary> /// Send message to the server /// </summary> /// <param name="message">Email message that we want to send</param> /// <param name="onSendCallBack">The deligated function which will be called after sending message.</param> public void Send(AbstractMailMessage message, SendCompletedEventHandler onSendCallBack = null) { SendCompleted += onSendCallBack; SendMailAsync(message); // Connecting to the server and configuring it using (var client = new SmtpSocketClient()) { if (String.IsNullOrEmpty(User)) { AuthenticationMode = AuthenticationType.UseDefaultCredentials; } } }