예제 #1
0
        public static void SendNotificationSystemNotice(Notification.NotificationSystem.Notice notice)
        {
            if (notice.NoticeType == Notification.NotificationSystem.NoticeType.Checkout)
            {
                if (Global.Library.Settings.TESTMODE)
                {
                    return;
                }
                if (notice is EmailNotice)
                {
                    var    en   = notice as EmailNotice;
                    string Body = en.Body;
                    new System.Threading.Thread(() =>
                    {
                        Body = Body.Replace("<name>", en.EmailAddress.Name);
                        var serviceToolString = " < br />";
                        foreach (var item in en.Assets)
                        {
                            serviceToolString += "(" + item + ")";
                        }

                        Body             = Body.Replace("<serviceTool>", serviceToolString);
                        Body             = Body.Replace("<serviceOrder>", en.NoticeControlNumber);
                        Body             = Body.Replace("<dateAssigned>", en.Created.ToShortDateString());
                        Body             = Body.Replace("<NL>", "<br />");
                        MailMessage msg  = new MailMessage();
                        msg.Subject      = "Return Request:: Job# " + en.NoticeControlNumber + " :: " + DateTime.Now.ToString();
                        msg.IsBodyHtml   = true;
                        msg.BodyEncoding = Encoding.ASCII;
                        msg.Body         = Body;
                        msg.From         = new MailAddress(Global.Library.Settings.SenderEmail);
                        foreach (var email in en.Emails)
                        {
                            msg.To.Add(email.Email);
                        }
                        string username               = Global.Library.Settings.SenderEmail;    //email address or domain user for exchange authentication
                        string password               = Global.Library.Settings.SenderPassword; //password
                        SmtpClient mClient            = new SmtpClient();
                        mClient.Host                  = Global.Library.Settings.SenderHost;
                        mClient.Port                  = Global.Library.Settings.SenderPort;
                        mClient.UseDefaultCredentials = false;
                        mClient.Credentials           = new NetworkCredential(username, password);
                        mClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        mClient.Timeout               = 100000;
                        mClient.EnableSsl             = true;
                        try
                        {
                            mClient.Send(msg);
                        }
                        catch
                        {
                        }
                    }).Start();
                }
            }
        }
예제 #2
0
        public static bool SendNotificationSystemNotice(Notification.NotificationSystem.Notice notice)
        {
            try
            {
                if (notice.NoticeType == Notification.NotificationSystem.NoticeType.Checkout)
                {
                    if (Global.Library.Settings.TESTMODE)
                    {
                        return(false);
                    }
                    if (notice is EmailNotice)
                    {
                        var    en   = notice as EmailNotice;
                        string Body = en.Body;


                        Body = Body.Replace("<name>", en.EmailAddress.Name);
                        var serviceToolString = " < br />";
                        foreach (var item in en.Assets)
                        {
                            serviceToolString += "(" + item + ")";
                        }

                        Body = Body.Replace("<serviceTool>", serviceToolString);
                        Body = Body.Replace("<customer>", en.Data);
                        Body = Body.Replace("<serviceOrder>", en.NoticeControlNumber);
                        Body = Body.Replace("<dateAssigned>", en.Created.ToShortDateString());
                        Body = Body.Replace("<NL>", "<br />");


                        var Subject = "Return Request:: Job# " + en.NoticeControlNumber + " :: " + DateTime.Now.ToString();

                        List <String> emails = new List <string>();
                        foreach (var email in en.Emails)
                        {
                            emails.Add(email.Email);
                        }

                        return(SendMassGmail(emails.ToArray(), Body, Subject));
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                Push.Alert("Email Fail:" + ex.Message);
                return(false);
            }
        }
예제 #3
0
 public static Task <bool> SendNotificationSystemNoticeAsync(Notification.NotificationSystem.Notice notice)
 {
     return(Task.FromResult(SendNotificationSystemNotice(notice)));
 }