示例#1
0
        // send mail to admin for publish note request
        public void PublishNot(string note, string seller)
        {
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "PublishNote" + ".cshtml");

            body = body.Replace("ViewBag.SellerName", seller);
            body = body.Replace("ViewBag.NoteTitle", note);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = _dbcontext.SystemConfigurations.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = seller + " sent his note for review";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#2
0
        //get string from email template TemporaryPassword.cshtml
        public void BuildTemporaryPasswordTemplate(User user, string temporarypassword)
        {
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "TemporaryPassword" + ".cshtml");

            body = body.Replace("ViewBag.TemporaryPassword", temporarypassword);
            body = body.Replace("ViewBag.FirstName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = user.EmailID.Trim();
            subject = "New Temporary Password has been created for you";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#3
0
 public ActionResult SendEmail(Email emailModel)
 {
     if (ModelState.IsValid)
     {
         _emailService.AddEmail(emailModel);
         bool result = SendingEmail.SendEmail(emailModel);
         if (result)
         {
             ViewBag.Message = "Your message has been sent successfully!";
         }
         else
         {
             ViewBag.Message = "Error sending message :(";
         }
         return(View("SendEmail"));
     }
     return(View("Contact", emailModel));
 }
示例#4
0
        // intializing the template that we want to send to admin for marking note as inappropriate
        private void SpamReportTemplate(SellerNotesReportedIssue spam, string membername)
        {
            string from, to, body, subject;

            // get all texts from SpamReport.cshtml from EmailTemplate
            body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "SpamReport" + ".cshtml");

            // get notes and user by using SellerNotesReportedIssue object
            var note   = _dbcontext.SellerNotes.Find(spam.NoteID);
            var seller = _dbcontext.Users.Find(note.SellerID);

            // replace some text with note title, seller name and user's name who mark this note as inappropriate
            body = body.Replace("ViewBag.SellerName", seller.FirstName + " " + seller.LastName);
            body = body.Replace("ViewBag.NoteTitle", note.Title);
            body = body.Replace("ViewBag.ReportedBy", membername);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = _dbcontext.SystemConfigurations.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = membername + " Reported an issue for " + note.Title;
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create object of MailMessage
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#5
0
        //get string from email template EmailVerification.cshtml
        public void BuildEmailVerifyTemplate(string baseurl, User user, string date)
        {
            // get text from email verification template
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "EmailVerification" + ".cshtml");

            // create url by user id and user registered date in string format
            var url = baseurl + "/Account/VerifyEmail?key=" + user.UserID + "&value=" + date;

            // replace url and first name
            body = body.Replace("ViewBag.ConfirmationLink", url);
            body = body.Replace("ViewBag.FirstName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = user.EmailID.Trim();
            subject = "Note Marketplace - Email Verification";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#6
0
        // for request to download we need to send mail to seller
        public void RequestPaidNotesTemplate(Downloads download, Users user)
        {
            // get all text from requestpaidnotes from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "RequestPaidNotes" + ".cshtml");
            //get seller
            var seller = context.Users.Where(x => x.ID == download.Seller).FirstOrDefault();

            // replace seller name and buyer name from template
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.BuyerName", user.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = seller.EmailID.Trim();
            subject = user.FirstName + " wants to purchase your notes";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail)
            SendingEmail.SendEmail(mail);
        }
        public void AllowDownloadTemplate(Downloads download, Users seller)
        {
            // get text from allowdownload template from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "SellerAllowDownloadTemplate" + ".cshtml");
            // get downloader user object
            var downloader = context.Users.Where(x => x.ID == download.Downloader).FirstOrDefault();

            // replace seller and buyer name
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.BuyerName", downloader.FirstName);
            body = body.ToString();

            // get support email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = downloader.EmailID.Trim();
            subject = seller.FirstName + " Allows you to download a note";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#8
0
        // send mail to admin
        public void BuildContactusTemplate(ContactUsViewModel contactusviewmodel)
        {
            string from, to, subject, bodytxt, body;

            // get all text from contactus from emailtemplate directory
            bodytxt = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "Contactus" + ".cshtml");
            // replace fullname and comment
            bodytxt = bodytxt.Replace("ViewBag.FullName", contactusviewmodel.FullName.Trim());
            bodytxt = bodytxt.Replace("ViewBag.Comment", contactusviewmodel.Comment.Trim());
            bodytxt = bodytxt.ToString();

            // get support email and notify email
            var fromemail = context.SystemConfiguration.Where(x => x.Key == "supportemail").FirstOrDefault();
            var tomail    = context.SystemConfiguration.Where(x => x.Key == "notifyemail").FirstOrDefault();

            // set from, to, subject, body
            from    = fromemail.Value.Trim();
            to      = tomail.Value.Trim();
            subject = contactusviewmodel.Subject + " - Query";
            StringBuilder sb = new StringBuilder();

            sb.Append(bodytxt);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }
示例#9
0
        public void UnpublishNoteTemplate(string remark, User seller)
        {
            // get text from unpublishnote template from emailtemplate directory
            string body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/EmailTemplate/") + "UnpublishNote" + ".cshtml");

            // replace seller and remark
            body = body.Replace("ViewBag.SellerName", seller.FirstName);
            body = body.Replace("ViewBag.Remark", remark);
            body = body.ToString();

            // get support email
            var fromemail = _dbcontext.SystemConfigurations.Where(x => x.Key == "supportemail").FirstOrDefault();

            // set from, to, subject, body
            string from, to, subject;

            from    = fromemail.Value.Trim();
            to      = seller.EmailID.Trim();
            subject = "Sorry! We need to remove your notes from our portal.";
            StringBuilder sb = new StringBuilder();

            sb.Append(body);
            body = sb.ToString();

            // create mailmessage object
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(from, "NotesMarketplace");
            mail.To.Add(new MailAddress(to));
            mail.Subject    = subject;
            mail.Body       = body;
            mail.IsBodyHtml = true;

            // send mail (NotesMarketplace/SendMail/)
            SendingEmail.SendEmail(mail);
        }