Send() public method

public Send ( MailMessage message ) : bool
message System.Net.Mail.MailMessage
return bool
Example #1
0
        public bool Send()
        {
            if (!string.IsNullOrEmpty(mailMessage.Body))
            {
                throw new Exception("You should not set body directly on MailMessage. Use Message!");
            }

            if (string.IsNullOrEmpty(From))
            {
                if (SendFromNoReplyAddress)
                {
                    // TODO
                    //From = siteSettings.GetSetting("Email/NoReplyEmail");
                }
                else
                {
                    // TODO
                    //From = siteSettings.GetSetting("Email/DefaultFromEmail");
                }
            }

            Diagnostics.Assert.EnsureStringValue(mailMessage.From.Address, "From address not specified");

            string fullBody = GetFullBody();

            if (TemplateVariables.Count > 0)
            {
                fullBody = Utilities.VelocityUtil.Evaluate(fullBody, TemplateVariables);
            }

            mailMessage.Body = fullBody;
            StandardSender sender = new StandardSender();
            bool           sendt  = sender.Send(mailMessage);

            mailMessage.Dispose();
            return(sendt);
        }
Example #2
0
        public bool Send()
        {
            if (!string.IsNullOrEmpty(mailMessage.Body))
            {
                throw new Exception("You should not set body directly on MailMessage. Use Message!");
            }

            if (string.IsNullOrEmpty(From))
            {
                if (SendFromNoReplyAddress)
                {
                    // TODO
                    //From = siteSettings.GetSetting("Email/NoReplyEmail");
                }
                else
                {
                    // TODO
                    //From = siteSettings.GetSetting("Email/DefaultFromEmail");
                }
            }

            Diagnostics.Assert.EnsureStringValue(mailMessage.From.Address, "From address not specified");

            string fullBody = GetFullBody();
            if (TemplateVariables.Count > 0)
            {
                fullBody = Utilities.VelocityUtil.Evaluate(fullBody, TemplateVariables);
            }

            mailMessage.Body = fullBody;
            StandardSender sender = new StandardSender();
            bool sendt = sender.Send(mailMessage);
            mailMessage.Dispose();
            return sendt;
        }