예제 #1
0
        private bool CreateMailMessage()
        {
            bool result = false;

            message = new MailMessage();

            MailAddress fromAddress = new MailAddress(FromAddress);

            message.From       = fromAddress;
            message.Subject    = Subject;
            message.IsBodyHtml = IsBodyHTML;
            message.Body       = BodyContent;

            if (ToAddresses.Count > 0)
            {
                message.To.Add(ToAddresses.ToSeparatedValues <string>(","));
            }

            if (CCAddresses.Count > 0)
            {
                message.CC.Add(CCAddresses.ToSeparatedValues <string>(","));
            }

            if (BCCAddresses.Count > 0)
            {
                message.Bcc.Add(BCCAddresses.ToSeparatedValues <string>(","));
            }

            result = true;

            return(result);
        }
예제 #2
0
        public bool SendMail(string Subject, string Body, bool HighPriority, string Attachment, string To, string CC, string From, string DisplayName, string Account, string Password, ref string errors)
        {
            if (String.IsNullOrWhiteSpace(To))
            {
                Logger.LogError(String.Format("Cannot add an empty To address to email with subject: {0}", Subject));
                return(false);
            }
            ToAddresses.Clear();              // need to clear any existing addresses that may have been added
            ToAddresses.Add(To);

            CCAddresses.Clear();
            CCAddresses.Add(CC);

            return(SendMail(Subject, Body, HighPriority, Attachment, ToAddresses, From, DisplayName, Account, Password, ref errors));
        }