コード例 #1
0
        public UserShows SendMessage(EmailMessage EmailMessage)
        {
            UserShows us = null;
            try
            {
                // if entered show, send email saying entered show
                us = new UserShows(EmailMessage.UserShowId);
                User user = new User(us.Userid);

                if (user.EmailAddress.Length < 5) {
                    throw new Exception("NoEmai");
                }
                Shows thisShow = new Shows(us.ShowID);
                String htmlContents = readTemplate("AdminEmailHandler", "html", thisShow, null);
                String plainContents = readTemplate("AdminEmailHandler", "txt", thisShow, null);

                htmlContents = htmlContents.Replace("[BODY]", EmailMessage.body.Replace("\n", "<br>"));
                plainContents = plainContents.Replace("[BODY]", EmailMessage.body);
                MailMessage mm = new MailMessage();

                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html);
                LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif);
                logoImage.ContentId = "LogoImage";
                //htmlView.LinkedResources.Add(logoImage);

                AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain);
                mm.Body = plainContents;
                mm.AlternateViews.Add(htmlView);

                SmtpClient client = new SmtpClient();
                mm.From = new MailAddress("*****@*****.**", "First Place Processing");
                mm.To.Add(new MailAddress(user.EmailAddress, user.Name));
                mm.Subject = EmailMessage.Subject;
                client.Send(mm);

                us.ContactStatus = 1;
                us.ContactDate = DateTime.Now;
                us.SaveContactDetails();
            }
            catch (Exception e)
            {
                AppException.LogEvent("SendMessage: "+ e.Message + " " + e.StackTrace);
            }
            return us;
        }
コード例 #2
0
        public void SendForRefund(int ShowID, int UserID)
        {
            Shows show = new Shows(ShowID);
            User user = new User(UserID);
            UserShows us = new UserShows(UserID, ShowID);
            var refcode = us.ID.ToString("000000");

            String htmlContents = readTemplate("Refund", "html", show, refcode);
            String plainContents = readTemplate("Refund", "txt", show, refcode);
            htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days");
            plainContents = plainContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days");

            MailMessage mm = new MailMessage();
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html);
            LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif);
            logoImage.ContentId = "LogoImage";
            //htmlView.LinkedResources.Add(logoImage);
            AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain);

            mm.AlternateViews.Add(plainView);
            mm.AlternateViews.Add(htmlView);

            SmtpClient client = new SmtpClient();
            mm.From = new MailAddress("*****@*****.**", "First Place Processing");
            mm.To.Add(new MailAddress(user.EmailAddress, user.Name));
            mm.Bcc.Add(new MailAddress("*****@*****.**", "Accounts"));
            mm.Subject = String.Format("Refund of entry {0} ({1:dd MMM yyyy})", show.ShowName, show.ShowDate);
            client.Send(mm);

            if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID)
            {
                mm = new MailMessage();
                mm.From = new MailAddress("*****@*****.**", "First Place Processing");
                mm.To.Add(new MailAddress("*****@*****.**", "First Place Processing"));
                mm.Subject = "Entry Refund Request";
                mm.Body = String.Format("Refund Request from {0}\r\n\r\nRefcode: {1}\r\n\r\nEmail: {2}\r\n\r\nShow: {3}\r\n",
                                        user.Name, refcode, user.EmailAddress, show.ShowName);
                client.Send(mm);
            }
        }