Exemple #1
0
        public void SendMsg(MailMsg msg, SendPriority?handlingPriority = null)
        {
            if (!Running || msg == null)
            {
                return;
            }
            var queues = m_Queues;

            if (queues == null)
            {
                return;
            }

            if (!handlingPriority.HasValue)
            {
                handlingPriority = SendPriority.Normal;
            }

            var queue = queues[(int)handlingPriority.Value];

            queue.Enqueue(msg);
            var trigger = m_Trigger;

            if (trigger != null)
            {
                trigger.Set();
            }
        }
Exemple #2
0
 /// <summary>
 /// Performs actual sending of msg. This method does not have to be thread-safe as it is called by a single thread
 /// </summary>
 public void SendMsg(MailMsg msg)
 {
     if (!Running)
     {
         return;
     }
     DoSendMsg(msg);
 }
Exemple #3
0
 /// <summary>
 /// Performs actual sending of msg. This method does not have to be thread-safe as it is called by a single thread
 /// </summary>
 protected abstract void DoSendMsg(MailMsg msg);
Exemple #4
0
    protected override void DoSendMsg(MailMsg msg)
    {
        if (msg==null || msg.TOAddress.IsNullOrWhiteSpace()) return;

           var fa = msg.FROMAddress;
           var fn = msg.FROMName;

           if (fa.IsNullOrWhiteSpace()) fa = DefaultFromAddress;
           if (fn.IsNullOrWhiteSpace()) fn = DefaultFromName;


           var from = new MailAddress(fa, fn);
           var to = new MailAddress(msg.TOAddress, msg.TOName);
                   
                  

           using (var email = new MailMessage(from, to))
           {

                email.Subject = msg.Subject;
               
                if (msg.CC.IsNotNullOrWhiteSpace())  email.CC.Add(msg.CC);
               
                if (msg.BCC.IsNotNullOrWhiteSpace()) email.Bcc.Add(msg.BCC);
                
                if (msg.HTMLBody.IsNullOrWhiteSpace())
                {
                  email.Body = msg.Body; 
                }
                else
                {
                  if (msg.Body.IsNullOrWhiteSpace())
                  {
                    email.IsBodyHtml = true;
                    email.Body = msg.HTMLBody;
                  }
                  else
                  {
                    email.Body = msg.Body;
                    var alternateHTML = AlternateView.CreateAlternateViewFromString(msg.HTMLBody, new System.Net.Mime.ContentType(ContentType.HTML)); 
                    email.AlternateViews.Add(alternateHTML);
                  }
                }

                m_Smtp.Send(email);
           }
    }
Exemple #5
0
        public void SendMsg(MailMsg msg, SendPriority? handlingPriority = null)
        {
            if (!Running || msg==null) return;
            var queues = m_Queues;
            if (queues==null) return;

            if (!handlingPriority.HasValue) handlingPriority = SendPriority.Normal;

            var queue =queues[(int)handlingPriority.Value];
            queue.Enqueue(msg);
            var trigger = m_Trigger;
            if (trigger!=null) trigger.Set();
        }
Exemple #6
0
        protected override void DoSendMsg(MailMsg msg)
        {
            if (msg == null || msg.TOAddress.IsNullOrWhiteSpace())
            {
                return;
            }

            var fa = msg.FROMAddress;
            var fn = msg.FROMName;

            if (fa.IsNullOrWhiteSpace())
            {
                fa = DefaultFromAddress;
            }
            if (fn.IsNullOrWhiteSpace())
            {
                fn = DefaultFromName;
            }


            var from = new MailAddress(fa, fn);
            var to   = new MailAddress(msg.TOAddress, msg.TOName);



            using (var email = new MailMessage(from, to))
            {
                email.Subject = msg.Subject;

                if (msg.CC.IsNotNullOrWhiteSpace())
                {
                    email.CC.Add(msg.CC);
                }

                if (msg.BCC.IsNotNullOrWhiteSpace())
                {
                    email.Bcc.Add(msg.BCC);
                }

                if (msg.HTMLBody.IsNullOrWhiteSpace())
                {
                    email.Body = msg.Body;
                }
                else
                {
                    if (msg.Body.IsNullOrWhiteSpace())
                    {
                        email.IsBodyHtml = true;
                        email.Body       = msg.HTMLBody;
                    }
                    else
                    {
                        email.Body = msg.Body;
                        var alternateHTML = AlternateView.CreateAlternateViewFromString(msg.HTMLBody, new System.Net.Mime.ContentType(ContentType.HTML));
                        email.AlternateViews.Add(alternateHTML);
                    }
                }

                m_Smtp.Send(email);
            }
        }
Exemple #7
0
 public void SendMsg(MailMsg msg, SendPriority?handlingPriority = null)
 {
 }
Exemple #8
0
 public void SendMsg(MailMsg msg, SendPriority? handlingPriority = null)
 {
 }