Пример #1
0
        public MailMessageWindow(MailMessageViewModel m)
        {
            InitializeComponent();

            txtBody.Text = m.Body;
            txtFrom.Text = m.From;
            txtTo.Text = m.To;
            txtSubject.Text = m.Subject;
        }
Пример #2
0
        public MailMessageWindow(MailMessageViewModel m)
        {
            InitializeComponent();


            txtBody.Text    = m.Body;
            txtFrom.Text    = m.From;
            txtTo.Text      = m.To;
            txtSubject.Text = m.Subject;
        }
Пример #3
0
        protected override IList <MailMessageViewModel> FillMessages()
        {
            IList <MailMessageViewModel> result = new List <MailMessageViewModel>();
            var message = MailMessageViewModel.Create();

            message.Date     = DateTime.Today.Date.AddHours(19).AddMinutes(19);
            message.From     = "John Heart";
            message.To       = "*****@*****.**";
            message.Subject  = "AsyncMode for Pivot Grid";
            message.Text     = DataHelper.GetMHTTextFromHTML("Cool will it work as normal if you use chart integration or need some modification?");
            message.Folder   = MessageFolderName.Management;
            message.IsReply  = true;
            message.Priority = MessagePriority.Low;
            result.Add(message);

            message          = MailMessageViewModel.Create();
            message.Date     = DateTime.Today.Date.AddHours(17).AddMinutes(54);
            message.From     = "Kobus Smit";
            message.Subject  = "XAF – Model Merge Tool";
            message.Text     = DataHelper.GetMHTTextFromHTML("Great! This is an useful enhancement that will save us time. One more step making XAF more RAD.");
            message.Folder   = MessageFolderName.IT;
            message.IsReply  = true;
            message.Priority = MessagePriority.Medium;
            result.Add(message);

            message         = MailMessageViewModel.Create();
            message.Date    = DateTime.Today.Date.AddHours(17).AddMinutes(11);
            message.From    = "Tony Taylor-Moran";
            message.Subject = "WinForms Tab Control - Custom Buttons";
            message.Text    = DataHelper.GetMHTTextFromHTML("Sorry, I don't agree with Chris at all, the assumption that Winforms is legacy doesn’t site right with me, " +
                                                            "quite a lot of my users are not interested, so I am more inclined to agree with the others. More attention really" +
                                                            " does need to be given to the Winforms collection of controls and in particular the MDITab control (My personal request!), the recent" +
                                                            " offerings haven’t seemed to give me much for the money (although I have a DXperience Enterprise Subscription, I really only use the " +
                                                            "WinForms controls) – &amp;nbsp;my subscription is due for renewal in May, unless I see something that is worth the renewal fee, I will " +
                                                            "give one of the other vendors a try.");
            message.Folder   = MessageFolderName.Sales;
            message.IsReply  = true;
            message.IsUnread = true;
            message.Priority = MessagePriority.Medium;
            result.Add(message);

            message               = MailMessageViewModel.Create();
            message.Date          = DateTime.Today.Date.AddDays(-2).AddHours(14).AddMinutes(20);
            message.From          = "Mehul Harry (DevExpress)";
            message.Subject       = "ASP.NET MVC - Code Usability Improvement";
            message.Text          = DataHelper.GetMHTTextFromHTML("Graeme, Thanks! And it's possible so we'll consider it for a future release.");
            message.Folder        = MessageFolderName.Support;
            message.IsUnread      = true;
            message.HasAttachment = true;
            message.Priority      = MessagePriority.High;
            result.Add(message);
            return(result);
        }
Пример #4
0
        public ActionResult SendMessage(MailMessageViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                string errorMessages = "<ul>";

                for (int i = 0; i < errors.Count; i++)
                {
                    ModelErrorCollection modelErrorCollection = errors[i];

                    for (int j = 0; j < modelErrorCollection.Count; j++)
                    {
                        if (!string.IsNullOrEmpty(modelErrorCollection[j].ErrorMessage))
                        {
                            errorMessages += "<li>";
                            errorMessages += modelErrorCollection[j].ErrorMessage;
                            errorMessages += "</li>";
                        }
                    }
                }

                errorMessages += "</ul>";

                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, errorMessages));
            }

            PesanPublikToAdmin pesan = new PesanPublikToAdmin();

            pesan.SenderName     = model.name;
            pesan.SenderEmail    = model.email;
            pesan.MessageContent = model.message;
            pesan.DateCreated    = DateTime.UtcNow;

            try
            {
                db.PesanPublikToAdmin.Add(pesan);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        static MailMessageViewModel CreateMessage(DataRow row)
        {
            MailMessageViewModel message = MailMessageViewModel.Create();

            message.Date          = DateTime.Now.AddDays((int)row["Day"]).AddSeconds(-new Random().Next(10000));
            message.From          = string.Format("{0}", row["From"]);
            message.Subject       = string.Format("{0}", row["Subject"]);
            message.IsUnread      = (DateTime.Now - message.Date) < TimeSpan.FromHours(200);
            message.Text          = string.Format("{0}", row["Text"]);
            message.HasAttachment = DataHelper.HasImages(message.Text);
            message.Folder        = GetFolder(row);
            message.IsReply       = (message.Subject).StartsWith("RE", StringComparison.InvariantCultureIgnoreCase);
            message.Priority      = message.IsReply ? MessagePriority.High : MessagePriority.Medium;
            message.To            = "Me";
            return(message);
        }
Пример #6
0
        public async Task SendAsync(MailMessageViewModel message)
        {
            try
            {
                var client = new SmtpClient(SMTP_SERVER, SMTP_PORT)
                {
                    Credentials = new NetworkCredential(SMTP_USER, Protected.DecodeText(PASSWORD)),
                    EnableSsl   = true
                };

                await client.SendMailAsync(new MailMessage(message.From, message.To)
                {
                    IsBodyHtml = message.IsBodyHtml,
                    Body       = message.Body,
                    Subject    = message.Subject
                });
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #7
0
        public ActionResult SendMessage()
        {
            MailMessageViewModel model = new MailMessageViewModel();

            return(View(model));
        }