SmtpMessageDirectSendDone Event |
Namespace: MailBee.SmtpMail
using System; using MailBee; using MailBee.SmtpMail; class Sample { // MessageDirectSendDone event handler. private static void OnMessageDirectSendDone(object sender, SmtpMessageDirectSendDoneEventArgs e) { Console.WriteLine("Sent using direct send to: " + e.SuccessfulRecipients.ToString()); } // MessageSent event handler. private static void OnMessageSent(object sender, SmtpMessageSentEventArgs e) { Console.WriteLine("In the long run, sent to: " + e.SuccessfulRecipients.ToString()); } // The actual code. static void Main(string[] args) { Smtp mailer = new Smtp(); // Get DNS servers from config file/OS settings. mailer.DnsServers.Autodetect(); // Specify backup SMTP server and enable ESMTP authentication. // Note, depending on your SMTP server settings, either // "jdoe" or "jdoe@domain.com" should be used as user account name. SmtpServer server = new SmtpServer("mail.isp.com", "jdoe", "secret"); server.Priority = 100; // low priority mailer.SmtpServers.Add(server); // Subscribe to events. mailer.MessageDirectSendDone += new SmtpMessageDirectSendDoneEventHandler(OnMessageDirectSendDone); mailer.MessageSent += new SmtpMessageSentEventHandler(OnMessageSent); // Send a message to 3 recipients on 2 domains. Let's assume we send // from a domain which has no its own MX record, and domain1.com checks // this and rejects our message to user1@domain1.com. In this case, // the message will be delivered to user1@domain1.com using ISP's mail // server (we assume ISP's mail server has MX record assigned). mailer.To.AsString = "user1@domain1.com, user2@domain1.com, user2@domain2.com"; mailer.From.Email = "sender@domain.com"; mailer.Subject = "Test message"; mailer.Send(); } }