示例#1
0
        private void DisplatchMailTest2(interoperabilita.CalendarMail.MailRequest request)
        {
            bool success = false;

            Chilkat.MailMan server = new Chilkat.MailMan()
            {
                SmtpHost     = "freesmtp.valueteam.com",
                SmtpUsername = "",
                SmtpPassword = ""
            };

            Chilkat.Email mail = new Chilkat.Email()
            {
                Subject = "This is a iCal test",
                Body    = "This is a iCal test",
                From    = "Organizer <*****@*****.**>"
            };

            server.UnlockComponent(ChilkatKeys.Mail);

            success = mail.AddTo("Attendee", "*****@*****.**");
            if (success != true)
            {
                throw new Exception(mail.LastErrorText);
            }

            success = mail.AddiCalendarAlternativeBody(request.AppointmentAsText, "REQUEST");
            if (success != true)
            {
                throw new Exception(mail.LastErrorText);
            }

            success = server.SendEmail(mail);
            if (success != true)
            {
                throw new Exception(server.LastErrorText);
            }

            success = server.CloseSmtpConnection();
            if (success != true)
            {
                throw new Exception("Connection to SMTP server not closed cleanly.");
            }
        }