Exemple #1
0
        public static void SendMail()
        {
            for (; NotificationGetParams.NotificPackQueue.Count != 0;)
            {
                lock (NotificationGetParams.lockObject)
                {
                    tempNotificPackIn = (NotificPackIn)NotificationGetParams.NotificPackQueue.Dequeue();
                }

                SendMailDo(tempNotificPackIn.eMailToPackIn, tempNotificPackIn.subjectPackIn, tempNotificPackIn.bodyPackIn, tempNotificPackIn.retryCounterPackIn,
                           tempNotificPackIn.eMailFrom_specialPackIn, tempNotificPackIn.smtpClient_specialPackIn, tempNotificPackIn.password_specialPackIn, tempNotificPackIn.port_specialPackIn,
                           tempNotificPackIn.highPriorityPackIn, tempNotificPackIn.eMailToCCPackIn, tempNotificPackIn.eMailToBCCPackIn, tempNotificPackIn.eMailAttachmentPackIn);
            }
        }
Exemple #2
0
        //#2 for Special Orign and Reveiver
        public static bool SetSendMail(MailAddress[] eMailTo, string subject, string body,
                                       int retryCounter, string smtpClient_special, MailAddress eMailFrom_special,
                                       string password_special, int?port_special, bool highPriority = false,
                                       MailAddress[] eMailToCC = null, MailAddress[] eMailToBCC = null, Attachment[] eMailAttachment = null)
        {
            NotificPackIn NotificPackIn = new NotificPackIn();

            NotificPackIn.eMailToPackIn            = eMailTo;
            NotificPackIn.subjectPackIn            = subject;
            NotificPackIn.bodyPackIn               = body;
            NotificPackIn.retryCounterPackIn       = retryCounter;
            NotificPackIn.smtpClient_specialPackIn = smtpClient_special;
            NotificPackIn.eMailFrom_specialPackIn  = eMailFrom_special;
            NotificPackIn.password_specialPackIn   = password_special;
            NotificPackIn.port_specialPackIn       = port_special;
            NotificPackIn.highPriorityPackIn       = highPriority;
            NotificPackIn.eMailToCCPackIn          = eMailToCC;
            NotificPackIn.eMailToBCCPackIn         = eMailToBCC;
            NotificPackIn.eMailAttachmentPackIn    = eMailAttachment;

            lock (lockObject)
            {
                NotificPackQueue.Enqueue(NotificPackIn);
            }

            if (sendMailThread == null || (sendMailThread.ThreadState == ThreadState.Stopped))
            {
                try
                {
                    sendMailThread = new Thread(new ThreadStart(NotificationSend.SendMail));
                    sendMailThread.Start();
                    return(true);
                }

                catch (Exception ex)
                {
                    Logging.Logger.Log("Sorry sir but I failed to send the Mail because:" + ex, Logging.Logger.MessageType.ERROR);
                    return(true);
                }
            }

            else
            {
                return(true);
            }
        }