Aspose.Email.Examples.CSharp.Email.ReceiveNotifications.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {
                // ExStart:ReceiveNotifications          
                // Create the message
                MailMessage msg = new MailMessage();
                msg.From = "[email protected]";
                msg.To = "[email protected]";
                msg.Subject = "the subject of the message";

                // Set delivery notifications for success and failed messages
                msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure;

                // Add the MIME headers
                msg.Headers.Add_("Disposition-Notification-To", "[email protected]");
                msg.Headers.Add_("Disposition-Notification-To", "[email protected]");

                // Send the message
                SmtpClient client = new SmtpClient("host", "username", "password");
                client.Send(msg);
                // ExEnd:ReceiveNotifications
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                
            }

        }
    }
ReceiveNotifications