Example #1
0
        public bool SendEmail(string toAddress, string subject, string body, bool ccRegistration)
        {
            if (Server == null || FromEmailAddress == null)
            {
                return(false);
            }

            MailMessage message = new MailMessage();

            try
            {
                message.To.Add(SmtpDirect.ClassicList(toAddress));
                message.From = new MailAddress(FromEmailAddress);

                if (ccRegistration && CCEmailAddress.Length != 0)
                {
                    message.CC.Add(SmtpDirect.ClassicList(CCEmailAddress));
                }
            }
            catch (Exception ex)
            {               // you should be calling CheckEmailAddy() first to avoid this error
                LogHelper.LogException(ex);
                return(false);
            }

            message.Subject = subject;
            message.Body    = body;

            return(Send(message));
        }
Example #2
0
        public bool SendEmail(string toAddress, string subject, string body, bool ccRegistration)
        {
            if (Server == null || FromEmailAddress == null)
            {
                return(false);
            }

            MailMessage message = new MailMessage();

            message.To.Add(SmtpDirect.ClassicList(toAddress));
            message.From = new MailAddress(FromEmailAddress);

            if (ccRegistration && CCEmailAddress.Length != 0)
            {
                message.CC.Add(SmtpDirect.ClassicList(CCEmailAddress));
            }

            message.Subject = subject;
            message.Body    = body;

            return(Send(message));
        }
Example #3
0
        // check the form of this address or list.
        // Under the message.to.Add is a call to System.Net.Mime.MailBnfHelper() which
        //  which validates the form
        public static bool CheckEmailAddy(string address, bool AllowList)
        {
            try
            {
                if (AllowList == false)
                {
                    if (address.IndexOf(',') >= 0 || address.IndexOf(';') >= 0)
                    {
                        return(false);
                    }
                }

                MailMessage message = new MailMessage();
                message.To.Add(SmtpDirect.ClassicList(address));
            }
            catch
            {               // bad format
                return(false);
            }
            // good form
            return(true);
        }