Пример #1
0
        public static void SendEmailWithAttachments(string toAddress, string toName, string subject, IEmailFormat message, bool highPriority, IList<string> attachmentFilenames)
        {
            var msg = new EmailMessage
            {
                ToEmailAddress = toAddress,
                ToName = toName,
                Subject = subject,
                Body = message.GetHtml(),
                IsBodyHtml = true,
                IsHighPriority = highPriority,
                FilesToAttach = attachmentFilenames ?? new List<string>()
            };

            EmailMessageAgent agent = null;
            try
            {
                agent = new EmailMessageAgent();
                agent.DispatchEmailMessage(msg);
            }
            finally
            {
                if (agent != null)
                    agent.Close();
            }
        }
Пример #2
0
        public static void SendEmail(string toAddress, string toName, string subject, IEmailFormat message, bool highPriority)
        {
            var msg = new EmailMessage
                          {
                              ToEmailAddress = toAddress,
                              ToName = toName,
                              Subject = subject,
                              Body = message.GetHtml(),
                              IsBodyHtml = true,
                              IsHighPriority = highPriority,
                            };

            EmailMessageAgent agent = null;
            try
            {
                agent = new EmailMessageAgent();
                agent.DispatchEmailMessage(msg);
            }
            finally
            {
                if (agent != null)
                    agent.Close();
            }
        }