Beispiel #1
0
        public void SaveEmailNoticeTest()
        {
            //Arrange
            var testMail = new EmailNotice2()
            {
                UserID          = "mif",
                SchoolYear      = schoolyear,
                SchoolCode      = "0204",
                PositionType    = "LTO",
                PositionID      = "20112",
                PositionTitle   = "Posting Title English Gr.6",
                PostingNum      = "2018-20122",
                NoticePrincipal = "School Principal Name",
                EmailType       = "Repost",
                EmailTo         = "*****@*****.**",
                EmailCC         = "*****@*****.**",
                EmailFrom       = "*****@*****.**",
                EmailSubject    = "Posting Reposting Notification",
                EmailBody       = "",
                EmailFormat     = "HTML",
                Attachment1     = "",
                Attachment2     = "",
                Attachment3     = "",
            };


            string expect = "Successfully";

            //Act
            var result = EmailNotification.SaveEmailNotice(testMail);


            //Assert
            Assert.AreEqual(expect, result, $"  RePosting email notification { result}");
        }
Beispiel #2
0
 public static string SendEmail(EmailNotice2 mailItems, System.Net.Mail.Attachment iCal)
 {
     try
     {
         SendEmail(mailItems);
         // string result = AssemblingeMail(eMailTo, eMailCC, eMailBcc, eMailForm, eMailSubject, eMailBody, eMailFormat, iCal);
         return("Successfully");
     }
     catch (Exception ex)
     {
         var em = ex.Message;
         return("Failed");
     }
 }
Beispiel #3
0
 public static string SaveEmailNotice(EmailNotice2 mailItems)
 {
     try
     {
         //  String sp = "dbo.tcdsb_LTO_ConfirmForHir_Log2 @UserID,@SchoolYear,@SchoolCode,@PositionType, @PositionID, @PositionTitle, @PostingNum, @NoticePrincipal, @EmailType,@EmailTo, @EmailCC, @EmailFrom, @EmailSubject, @EmailBody";
         string sp     = "dbo.tcdsb_LTO_EmailNotificaiton_Log @UserID,@SchoolYear,@SchoolCode,@PositionType, @PositionID, @PositionTitle, @PostingNum, @NoticePrincipal, @NoticeFor,@EmailType,@EmailTo, @EmailCC, @EmailFrom, @EmailSubject, @EmailBody";
         string result = GeneralDataAccess.TextValue(sp, mailItems);
         return(result);
     }
     catch (Exception ex)
     {
         var exm = ex.Message;
         return("Failed");
     }
 }
Beispiel #4
0
        public static string SendEmail(EmailNotice2 mailItems)
        {
            string result = "Failed";

            var eMailTo   = mailItems.EmailTo;
            var eMailCC   = mailItems.EmailCC;
            var eMailBcc  = mailItems.EmailBcc;
            var eMailBody = CheckTestBody(mailItems.EmailBody, eMailTo, eMailCC, eMailBcc);

            if (eMailTo != "")
            {
                System.Net.Mail.SmtpClient myMail = new System.Net.Mail.SmtpClient();
                myMail.Host = WebConfigurationManager.AppSettings["SMTPServer"];

                System.Net.Mail.MailMessage Mailmsg = new System.Net.Mail.MailMessage();
                try
                {
                    if (WebConfigValue.eMailGo() == "Test" || WebConfigValue.eMailGo() == "Attack")
                    {
                        eMailTo  = $"{mailItems.UserID}@tcdsb.org"; // userID + "@tcdsb.org";
                        eMailCC  = "*****@*****.**";
                        eMailBcc = "";
                    }

                    Mailmsg = GetEmailMsg(eMailTo, eMailCC, eMailBcc, eMailBody, mailItems);
                    myMail.Send(Mailmsg);

                    result = "Successfully";
                }
                catch (Exception ex)
                {
                    var em = ex.Message;
                }
                Mailmsg.Dispose();
            }
            else
            {
                result = "No Email Recieve";
            }

            return(result);
            //   NotificationeMail("Save", userID, schoolyear, schoolcode, employeeID, noticeType, noticeDate, deadlineDate, deadlineDate, eMailSubject, eMailBody);
            // string result = AssemblingeMail(eMailTo, eMailCC, eMailBcc, mailItems.EmailFrom, mailItems.EmailSubject, eMailBody, mailItems.EmailFormat);
        }
Beispiel #5
0
        private static System.Net.Mail.MailMessage GetEmailMsg(string eMailTo, string eMailCC, string eMailBcc, string eMailBody, EmailNotice2 mailItems)
        {
            try
            {
                //  System.Net.Mail.SmtpClient myMail = new System.Net.Mail.SmtpClient();
                //   myMail.Host = WebConfigurationManager.AppSettings["SMTPServer"];

                System.Net.Mail.MailMessage Mailmsg = new System.Net.Mail.MailMessage();
                Mailmsg.To.Clear();
                LoopAddress("mailTo", eMailTo, ref Mailmsg);
                LoopAddress("mailCC", eMailCC, ref Mailmsg);
                LoopAddress("mailBcc", eMailBcc, ref Mailmsg);
                LoopAddress("mailFrom", mailItems.EmailFrom, ref Mailmsg);


                Mailmsg.Subject  = mailItems.EmailSubject;
                Mailmsg.Priority = MailPriority.High;
                if (mailItems.EmailFormat == "HTML")
                {
                    Mailmsg.IsBodyHtml = true;
                }
                Mailmsg.Body = eMailBody;

                if (!string.IsNullOrEmpty(mailItems.Attachment1))
                {
                    AddAttachments(mailItems.Attachment1, ref Mailmsg);
                }
                if (!string.IsNullOrEmpty(mailItems.Attachment2))
                {
                    AddAttachments(mailItems.Attachment2, ref Mailmsg);
                }
                if (!string.IsNullOrEmpty(mailItems.Attachment3))
                {
                    AddAttachments(mailItems.Attachment3, ref Mailmsg);
                }
                return(Mailmsg);
            }
            catch
            {
                return(null);
            }
        }