Example #1
0
        public async Task <ActionResult> Email(FormCollection fc)
        {
            var          sd = db.Students.ToList();
            var          s  = sd.Count();
            string       cc;
            EmailService service = new App_Start.EmailService();
            var          std     = db.Students.ToList().Select(x => new Student
            {
                ID           = x.ID,
                EmailAddress = x.EmailAddress
            }).ToList();

            foreach (var student in std)
            {
                //MailAddress cc = new MailAddress(fc["cc"]);
                IdentityMessage message = new IdentityMessage();
                cc = fc["cc"].ToString();

                if (!string.IsNullOrEmpty(cc))
                {
                    message.Destination += ";" + cc;
                }

                message.Destination = student.EmailAddress;
                message.Body        = fc["message"];
                message.Subject     = fc["subject"];
                await service.SendAsync(message);
            }
            ViewBag.stdcount = s;
            SetSchoolInformation();
            return(View());
        }
Example #2
0
        public async Task <ActionResult> StudentDetails(string id, FormCollection fc)
        {
            string          cc;
            var             student = db.Students.Where(x => x.StudentID == id).FirstOrDefault();
            EmailService    service = new App_Start.EmailService();
            IdentityMessage message = new IdentityMessage();

            cc = fc["cc"].ToString();
            if (!string.IsNullOrEmpty(cc))
            {
                message.Destination += ";" + cc;
            }
            message.Destination = student.EmailAddress;
            message.Body        = fc["message"];
            message.Subject     = fc["subject"];
            await service.SendAsync(message);

            SetSchoolInformation();
            return(View(student));
        }
Example #3
0
        public async Task <ActionResult> EmailtoAdmin(string id, FormCollection fc)
        {
            //  string cc;

            var    data = db.Distributors.Where(x => x.UserName == "Admin").FirstOrDefault();
            string str  = data.EmailAddress;
            //ViewBag.adminemail = str;

            var                         student = db.Students.Where(x => x.StudentID == id).FirstOrDefault();
            EmailService                service = new App_Start.EmailService();
            IdentityMessage             message = new IdentityMessage();
            Dictionary <string, string> param   = new Dictionary <string, string>();

            param.Add("<%Name%>", fc["yourname"]);
            param.Add("<%Phone%>", fc["phone"]);
            param.Add("<%Email%>", fc["youremail"]);
            param.Add("<%Message%>", fc["message"]);
            string body = ShrdMaster.Instance.buildEmailBody("ContactUsTemplate.txt", param);

            message.Destination = str;
            message.Body        = body;
            Organization org = null;

            if (Session["Organization"] != null)
            {
                org = Session["Organization"] as Organization;
                if (org == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }

            message.Subject = "Enquiry www.fundraising.com: From " + org.Name;

            await service.SendAsync(message);

            SetSchoolInformation();

            return(View(student));
        }