public static void Run()
        {
            // ExStart:ForwardEmail
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_SMTP();

            //Create an instance of SmtpClient class
            SmtpClient client = new SmtpClient();

            // Specify your mailing host server, Username, Password, Port and SecurityOptions
            client.Host = "mail.server.com";
            client.Username = "******";
            client.Password = "******";
            client.Port = 587;
            client.SecurityOptions = SecurityOptions.SSLExplicit;
            MailMessage message = MailMessage.Load(dataDir + "Message.eml");
            client.Forward("*****@*****.**", "*****@*****.**", message);
            // ExEnd:ForwardEmail
        }
Exemple #2
0
        public static void Run()
        {
            // ExStart:ForwardEmail
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_SMTP();

            //Create an instance of SmtpClient class
            SmtpClient client = new SmtpClient();

            // Specify your mailing host server, Username, Password, Port and SecurityOptions
            client.Host            = "mail.server.com";
            client.Username        = "******";
            client.Password        = "******";
            client.Port            = 587;
            client.SecurityOptions = SecurityOptions.SSLExplicit;
            MailMessage message = MailMessage.Load(dataDir + "Message.eml");

            client.Forward("*****@*****.**", "*****@*****.**", message);
            // ExEnd:ForwardEmail
        }
Exemple #3
0
        public static void Run()
        {
            //ExStart: ForwardEmailWithoutUsingMailMessage
            string dataDir = RunExamples.GetDataDir_Email();

            string host     = "mail.server.com";
            string username = "******";
            string password = "******";
            int    smtpPort = 587;
            string sender   = "*****@*****.**";
            MailAddressCollection recipients = new MailAddressCollection();

            recipients.Add("[email protected], [email protected]");

            using (SmtpClient client = new SmtpClient(host, smtpPort, username, password, SecurityOptions.Auto))
            {
                string fileName = @"test.eml";
                using (FileStream fs = File.OpenRead(dataDir + fileName))
                {
                    client.Forward(sender, recipients, fs);
                }
            }
            //ExEnd: ForwardEmailWithoutUsingMailMessage
        }