Пример #1
0
        public IHttpActionResult SendEmail(EmailData emailData)
        {
            try
            {
                if (emailData == null)
                {
                    return(BadRequest("Service Status cannot be null"));
                }

                //TODO: get informations in database
                string host      = "smtp.gmail.com";
                string emailFrom = "*****@*****.**";
                string user      = "******";
                string password  = "******";
                int    port      = 587;
                string subject   = GetEmailSubject();
                string body      = GetEmailBody(String.IsNullOrEmpty(emailData.Message) ? "" : emailData.Message);
                //

                EmailHelper.SendEmail(host, emailFrom, emailData.Email, subject, body, user, password, port);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #2
0
        private static MimeEntity GenerateEmailBody(EmailData data, string webAppBaseUrl)
        {
            string template;

            if (data.Type == EmailTypeEnum.Verification)
            {
                template = System.IO.File.ReadAllText("wwwroot\\EmailTemplates\\EmailVerification.html");
                Handlebars.RegisterHelper("signupLink", (writer, context, parameters) =>
                {
                    writer.WriteSafeString($"{webAppBaseUrl}email-verified?token={data.Token}");
                });
            }
            else
            {
                template = System.IO.File.ReadAllText("wwwroot\\EmailTemplates\\PasswordRecovery.html");
                Handlebars.RegisterHelper("resetPasswordUrl", (writer, context, parameters) =>
                {
                    writer.WriteSafeString($"{webAppBaseUrl}reset-password?token={data.Token}");
                });
            }

            var compiledTemplate = Handlebars.Compile(template);

            var builder = new BodyBuilder {
                HtmlBody = compiledTemplate(data)
            };

            return(builder.ToMessageBody());
        }
Пример #3
0
        public ActionResult AddAdminView(ViewModelData viewModelData)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Account newAccount = viewModelData.Account;
                    if (!accountRepository.CheckAccount(newAccount))
                    {
                        accountRepository.Add(newAccount);
                        Message message = new Message
                        {
                            Subject   = "Account Created",
                            Recepient = newAccount.UserEmail,
                            Body      = "A brand new Keiki Admin account was created with your email. If this was not you, please contact this number 000-000-0000"
                        };
                        EmailData emailData = new EmailData(message);

                        return(GoToMainRecordView(newAccount.Id));
                    }
                }
                catch (Exception ex)
                {
                    //Add error
                    ViewBag.Message = ex;
                    return(View(viewModelData));
                }
            }

            ViewBag.Message = "Missing or Incorrect Data";
            return(View(viewModelData));
        }
        public IHttpActionResult AcceptReponse(int id)
        {
            try
            {
                EmailData UpdateStatus = new EmailData();
                UpdateStatus = _context.EmailsData.FirstOrDefault(c => c.Id == id);

                if (UpdateStatus != null)
                {
                    if (UpdateStatus.StatusId == 2)
                    {
                        UpdateStatus.StatusId = 3;
                        _context.SaveChanges();
                        return(Ok("Response Recored"));
                    }
                    else if (UpdateStatus.StatusId == 3)
                    {
                        return(Ok("Response Recored"));
                    }
                    else if (UpdateStatus.StatusId == 3)
                    {
                        return(Ok("Your respnse has already acknowledged"));
                    }
                }

                return(BadRequest("Response Not Recored"));
            }
            catch (Exception)
            {
                return(BadRequest("Response Not Recored"));
            }
        }
        /// <summary>
        /// Notifies contacts via multilanguage templates.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="parameters">Parameters.</param>
        public virtual void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            if (EmailWithMacrosManager == null)
            {
                EmailWithMacrosManager = new EmailWithMacrosManager(userConnection);
            }
            EmailData emailData = new EmailData();

            emailData.ParseParameters(parameters);
            if (userConnection.GetIsFeatureEnabled("EmailMessageMultiLanguageV2"))
            {
                SendEmail(emailData, emailData.TplId);
            }
            else
            {
                if (TemplateLoader == null)
                {
                    TemplateLoader = new EmailTemplateStore(userConnection);
                }
                if (EmailTemplateLanguageHelper == null)
                {
                    EmailTemplateLanguageHelper = new EmailTemplateLanguageHelper(emailData.CaseId, userConnection);
                }
                Guid   languageId     = EmailTemplateLanguageHelper.GetLanguageId(emailData.TplId, TemplateLoader);
                Entity templateEntity = TemplateLoader.GetTemplate(emailData.TplId, languageId);
                SendEmail(emailData, templateEntity.PrimaryColumnValue);
            }
        }
Пример #6
0
        public IHttpActionResult SendEmail(EmailModel emailModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Not a valid model"));
                }
                else
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <EmailModel, EmailDTO>();
                    });
                    IMapper mapper = config.CreateMapper();

                    var emailResultData = mapper.Map <EmailModel, EmailDTO>(emailModel);

                    string powerBIUserName = ConfigurationManager.AppSettings["powerBIUserName"];
                    string powerBIPWD      = ConfigurationManager.AppSettings["powerBIPWD"];
                    string smtpHost        = ConfigurationManager.AppSettings["smtpHost"];
                    int    smtpPort        = Convert.ToInt32(ConfigurationManager.AppSettings["smtpPort"]);

                    EmailData emailData = new EmailData();

                    emailData.SendEmail(powerBIUserName, powerBIPWD, smtpHost, smtpPort, emailResultData.ToEmail, emailResultData.Subject, emailResultData.Body);

                    return(Created("api/SendEmail", true));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("Send email failed"));
            }
        }
Пример #7
0
        /// <summary>
        /// SMTP configuration
        /// </summary>
        public static async Task <string> SetEmailFromBody([FromBody] EmailData data)
        {
            _logger.Info("[SetEmailFromBody] Method started");

            try
            {
                var deviceInfoData = await GetRequests.DeviceInfo();

                var serial = $"HK-{deviceInfoData.deviceInfo.serialNumber}@camera.ru";                  //[email protected]
                data.mailing.sender.emailAddress = serial;
                data.mailing.receiverList.receiver[0].emailAddress = serial;

                using var xmlData = Converters.ToStringContent(data, "mailing");
                var response = await WebClient.Client.PutAsync("System/Network/mailing/1", xmlData).Result.Content.ReadAsStringAsync();

                var jsonResponse = Converters.XmlToJson(response);
                var responseData = JsonConvert.DeserializeObject <CamResponses>(jsonResponse);

                _logger.Info("[SetEmailFromBody] Method has complete");
                return($"{responseData.responseStatus.StatusString,-10} Request url {responseData.responseStatus.RequestUrl}");
            }
            catch (Exception e)
            {
                _logger.Error($"[SetEmailFromBody] Method failed. \nError message: {e.Message}");
                return(e.Message);
            }
        }
Пример #8
0
        public async Task <bool> SendEmail(EmailData data)
        {
            var sender = await UnitOfWork.Users.GetByEmailAsync(data.Email);

            if (sender == null)
            {
                return(false);
            }
            var builder = new StringBuilder(File.ReadAllText(HostingEnvironment.MapPath(@"~/Templates/EmailTemplates/AbsenceTemplate.html")));

            builder.Replace(Constants.MailConstants.FirstName, sender.FirstName);
            builder.Replace(Constants.MailConstants.LastName, sender.LastName);
            builder.Replace(Constants.MailConstants.Time, data.Date);
            builder.Replace(Constants.MailConstants.Mesage, data.Text);
            var emailMessage = new MailMessage
            {
                From         = new MailAddress(sender.Username, sender.Username),
                Subject      = $"{data.Type}     {data.Date}",
                Priority     = MailPriority.Normal,
                Body         = builder.ToString(),
                BodyEncoding = Encoding.UTF8,
                IsBodyHtml   = true
            };

            emailMessage.To.Add(Constants.SmtpSettingsConstants.DefaultSmtpSettings.Username);
            return(await ServiceLocator.Current.Get <IEmailService>().SendMailAsync(emailMessage));
        }
        public ActionResult <EmailData> Create(EmailData data)
        {
            //Enviar correo con un link para cambiar contraseña

            EmailMessage message = new EmailMessage();

            message.Content = $"<div class='margin:10px'>Name: {data.name}<br/>Address: {data.email}</div><br/><br/>Message:<br/>" + data.message;
            message.Subject = "Encrypted Box Contact!";
            message.To.Add(new EmailAddress {
                Name = "Encrypted Box", Address = "*****@*****.**"
            });
            string error = string.Empty;

            try
            {
                _email.Send(message);
            }
            catch (System.Exception ex)
            {
                error = ex.InnerException.ToString();
                System.Diagnostics.Trace.TraceError(ex.InnerException.ToString());
            }


            return(Ok(error));
        }
Пример #10
0
        private void Button_Click_1(object sender, RoutedEventArgs e)//Logging in
        {
            EmailUser logged;
            string    user     = this.Username.Text;
            string    password = this.Password.Password;
            bool      success  = EmailData.GetUserData(user, password, out logged);

            if (!success)
            {
                MessageBox.Show($"{this.FindResource("LoginFail") as string}");
            }
            else
            {
                if (this.Owner is MainWindow wnd)
                {
                    wnd.current = logged;
                    wnd.TabControl.Visibility = System.Windows.Visibility.Visible;
                    wnd.logged     = true;
                    wnd.Login.Text = this.FindResource("StrLogout") as string;
                    wnd.NewMailButton.IsEnabled = true;
                    wnd.SearchBox.IsEnabled     = true;
                }
                this.Close();
            }
        }
    public static void Test()
    {
        string baseURI = "http://*****:*****@bar.com",
            Enc64FileContents = fileContents,
            FileName          = "test.txt"
        };
        XNamespace ns = "http://somenamespace/";
        XElement   emailDataElement = new XElement(ns + "EmailData");

        emailDataElement.Add(new XElement(ns + "FileName", emailData.FileName));
        emailDataElement.Add(new XElement(ns + "EmailAddress", emailData.EmailAddress));
        emailDataElement.Add(new XElement(ns + "Enc64FileContents", emailData.Enc64FileContents));
        var xml = emailDataElement.ToString(SaveOptions.DisableFormatting);

        using (WebClient wc = new WebClient())
        {
            wc.Headers[HttpRequestHeader.ContentType] = "application/xml; charset=utf-8";
            string response = wc.UploadString(URI, "POST", xml);
            Console.WriteLine(response);
        }
    }
Пример #12
0
        public bool SendEmailAsync(string sender, string displayName, string recipient, string subject, string body, bool isBodyHtml, string Bcc = null)
        {
            EmailData info = new EmailData();

            info.Body        = body;
            info.Sender      = sender;
            info.DisplayName = displayName;
            info.Recipient   = recipient;
            info.Subject     = subject;
            info.IsBodyHtml  = isBodyHtml;
            info.BCC         = Bcc;

            try
            {
                this.SendEmail(info);
                return(true);
            }
            catch (Exception ex)
            {
                LoggingManager.Instance.SaveErrorLog(ex);
                //CustomLoggingManager.Instance.Log(Guid.NewGuid(), ex, string.Empty);
                //MailingManager.Instance.SendErrorEmail(ex);
                return(false);
            }
        }
Пример #13
0
        private static bool TriggerMail(string source, string serviceName, bool isStartSuccess, string body)
        {
            using (MetricTracker.Track(MethodBase.GetCurrentMethod()))
            {
                var msgServiceStartTry = isStartSuccess ? Constants.MsgServiceRestartSuccess : Constants.MsgServiceRestartFail;
                var backgroundColor    = isStartSuccess ? Constants.Green : Constants.Red;

                body = string.Format(Constants.BodyTemplate.Replace(Environment.NewLine, string.Empty).Replace("\t", string.Empty), Constants.Restart, backgroundColor, msgServiceStartTry, body);

                var emailData = new EmailData
                {
                    Subject               = string.Format(Constants.SubjectTemplate, serviceName),
                    Body                  = body,
                    IsBodyHtml            = true,
                    FromMailAddress       = Config.EmailSection.FromMailAddress,
                    FromDisplayName       = Config.EmailSection.FromDisplayName,
                    ToMailAddress         = Config.EmailSection.ToMailAddress,
                    FromMailPassword      = Config.SecureSection.FromMailPassword,
                    Host                  = Config.EmailSection.Host,
                    Port                  = Config.EmailSection.Port,
                    EnableSsl             = Config.EmailSection.EnableSsl,
                    TimeOutInMilliseconds = Config.EmailSection.TimeoutInMilliseconds
                };

                return(MailSender.SendMail(emailData, source));
            }
        }
Пример #14
0
 private void GetReceivedUids(EmailData account)
 {
     using (var ctx = new DbMailRepository())
     {
         _receivedMessagesUids = ctx.GetReceivedUidsOnDate(account.InquireDate, account.Email) ?? new List <string>();
     }
 }
Пример #15
0
        public void EmailStatusUpdate_EmailIsComplained_ReplyFailed()
        {
            const EmailStatus emailStatus = EmailStatus.Complained;
            var emailData = new EmailData
            {
                ToAddress = "toaddress"
            };
            var requestMessage = new ScheduleEmailForSendingLater(DateTime.Now.AddMinutes(5), emailData, new SmsMetaData(), Guid.NewGuid(), "username");
            var data           = new ScheduledEmailData
            {
                ScheduleMessageId   = requestMessage.CorrelationId,
                OriginalMessageData = new OriginalEmailMessageData(requestMessage)
            };
            var emailStatusUpdate = new EmailStatusUpdate {
                Status = emailStatus
            };

            Test.Initialize();
            Test.Saga <EmailScheduler>()
            .WithExternalDependencies(a => { a.Data = data; })
            .WhenReceivesMessageFrom("address")
            .ExpectPublish <ScheduledEmailFailed>(m =>
                                                  m.CoordinatorId == requestMessage.CorrelationId &&
                                                  m.EmailStatus == emailStatus &&
                                                  m.ScheduledSmsId == data.ScheduleMessageId &&
                                                  m.ToAddress == emailData.ToAddress &&
                                                  m.Username == requestMessage.Username)
            .ExpectSendLocal <ScheduleStatusChanged>(s =>
                                                     s.Status == MessageStatus.Failed &&
                                                     s.ScheduleId == data.ScheduleMessageId)
            .When(s => s.Handle(emailStatusUpdate))
            .AssertSagaCompletionIs(true);
        }
Пример #16
0
        public bool SendEmail(EmailData emailData)
        {
            try
            {
                MimeMessage emailMessage = new MimeMessage();

                MailboxAddress emailFrom = new MailboxAddress(_emailSettings.Name, _emailSettings.EmailId);
                emailMessage.From.Add(emailFrom);

                MailboxAddress emailTo = new MailboxAddress(emailData.EmailToName, emailData.EmailToId);
                emailMessage.To.Add(emailTo);

                emailMessage.Subject = emailData.EmailSubject;

                BodyBuilder emailBodyBuilder = new BodyBuilder();
                emailBodyBuilder.TextBody = emailData.EmailBody;
                emailMessage.Body         = emailBodyBuilder.ToMessageBody();

                SmtpClient emailClient = new SmtpClient();
                emailClient.Connect(_emailSettings.Host, _emailSettings.Port, _emailSettings.UseSSL);
                emailClient.Authenticate(_emailSettings.EmailId, _emailSettings.Password);
                emailClient.Send(emailMessage);
                emailClient.Disconnect(true);
                emailClient.Dispose();

                return(true);
            }
            catch (Exception ex)
            {
                //Log Exception Details
                return(false);
            }
        }
Пример #17
0
        public static void Send(EmailData email)
        {
            SmtpClient  smtpClient  = new SmtpClient(email.Host, email.Port);
            MailMessage mailMessage = new MailMessage()
            {
                From = new MailAddress(email.From, email.DisplayName)
            };

            foreach (var itemTo in email.To)
            {
                mailMessage.To.Add(itemTo);
            }

            foreach (var bcc in ConfigurationManager.AppSettings["Email.Bcc"].Split(new[] { ',' },
                                                                                    StringSplitOptions.RemoveEmptyEntries))
            {
                mailMessage.Bcc.Add(bcc);
            }

            mailMessage.Subject    = email.Subcaject;
            mailMessage.Body       = email.Body;
            mailMessage.IsBodyHtml = true;

            if (!string.IsNullOrEmpty(email.Credentiales.UserName) && !string.IsNullOrEmpty(email.Credentiales.Password))
            {
                smtpClient.Credentials = new NetworkCredential(email.Credentiales.UserName, email.Credentiales.Password);
                //smtpClient.EnableSsl = true;
            }
            else
            {
                smtpClient.UseDefaultCredentials = true;
            }
            smtpClient.Send(mailMessage);
        }
Пример #18
0
        public void EmailStatusUpdate_EmailIsDelivered_SetsTimeoutForFurtherInformation_TimeoutExpires_PublishSuccess()
        {
            const EmailStatus emailStatus = EmailStatus.Delivered;
            var emailData = new EmailData
            {
                ToAddress = "toaddress"
            };
            var requestMessage = new ScheduleEmailForSendingLater(DateTime.Now.AddMinutes(5), emailData, new SmsMetaData(), Guid.NewGuid(), "username");
            var data           = new ScheduledEmailData
            {
                ScheduleMessageId   = requestMessage.CorrelationId,
                OriginalMessageData = new OriginalEmailMessageData(requestMessage)
            };
            var emailStatusUpdate = new EmailStatusUpdate {
                Status = emailStatus
            };

            Test.Initialize();
            Test.Saga <EmailScheduler>()
            .WithExternalDependencies(a => { a.Data = data; })
            .WhenReceivesMessageFrom("address")
            .ExpectTimeoutToBeSetIn <ScheduleEmailDeliveredTimeout>((message, timespan) => timespan.Ticks == new TimeSpan(1, 0, 0, 0).Ticks)
            .When(s => s.Handle(emailStatusUpdate))
            .ExpectPublish <ScheduledEmailSent>(m =>
                                                m.CoordinatorId == requestMessage.CorrelationId &&
                                                m.EmailStatus == emailStatus &&
                                                m.ScheduledSmsId == data.ScheduleMessageId &&
                                                m.ToAddress == emailData.ToAddress &&
                                                m.Username == requestMessage.Username)
            .ExpectSendLocal <ScheduleStatusChanged>(s =>
                                                     s.Status == MessageStatus.Sent &&
                                                     s.ScheduleId == data.ScheduleMessageId)
            .WhenSagaTimesOut()
            .AssertSagaCompletionIs(true);
        }
Пример #19
0
 private void SetMockEmails()
 {
     MockEmails = new Mock <DbSet <Email> >().SetupData(EmailData.Data());
     MockEmails.Setup(x => x.Find(It.IsAny <object[]>())).Returns <object[]>(ids => EmailData.Data().FirstOrDefault(d => d.EmailId == (int)ids[0]));
     MockEmails.Setup(x => x.FindAsync(It.IsAny <object[]>())).Returns <object[]>(ids => Task.FromResult(EmailData.Data().FirstOrDefault(d => d.EmailId == (int)ids[0])));
     MockContext.Setup(x => x.Emails).Returns(MockEmails.Object);
 }
Пример #20
0
        public bool SendEmail(int emailId)
        {
            if (emailId <= 0)
            {
                _logger.Error("Incorrect emailId: " + emailId);
                return(false);
            }
            EmailData emailData = _databaseManager.GetEmailData(emailId);

            if (emailData == null)
            {
                _logger.Error("Email data is null (emailId: " + emailId + ")");
                return(false);
            }
            EmailMessage emailMessage = _emailMessageCreator.CreateEmailMessage(emailData);

            if (!ValidateEmailMessage(emailMessage))
            {
                _logger.Error("Email message is not valid (emailId: " + emailId + ")");
                return(false);
            }
            try
            {
                _emailSender.SendEmail(emailMessage);
                _logger.Info("Email was sent!");
            }
            catch (Exception ex)
            {
                _logger.Exception(ex.ToString());
                return(false);
            }
            return(true);
        }
Пример #21
0
        public JsonResult sendEmail(EmailData data)
        {
            string from     = "*****@*****.**";
            string password = "******";
            string subject  = data.subject;
            string body     = data.message;

            foreach (var contact in data.emails)
            {
                Thread email = new Thread(delegate()
                {
                    SendEmail(contact.email, from, password, subject, body);
                });

                email.IsBackground = true;
                email.Start();
            }

            ResponseNotification response = new ResponseNotification();

            response.Success = true;
            response.Message = "Correos enviados exitosamente";

            var jsonResult = Json(response, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Пример #22
0
    //测试用
    void Test()
    {
        List <EmailData> listEmailData = new List <EmailData>();

        for (int i = 0; i < 5; i++)
        {
            if (i == 0)
            {
                EmailData email = new EmailData()
                {
                    emailId = (i + 1).ToString(), rcNum = null, goldNum = null, content = string.Format("你得到房卡{0}张,你得到金币0块", i), title = "购买房卡"
                };
                listEmailData.Add(email);
            }
            else
            {
                EmailData email = new EmailData()
                {
                    emailId = (i + 1).ToString(), rcNum = (i).ToString(), goldNum = 2.ToString(), content = string.Format("你得到房卡{0}张,你得到金币2块", i), title = "购买房卡"
                };
                listEmailData.Add(email);
            }
        }

        EmailManager.Instance.UpdateNoReadList(listEmailData);
        InitNoReadEmailView();
    }
Пример #23
0
        public void GetDataFromExcelReturnsData()
        {
            var emailData = new EmailData();
            var results   = emailData.GetCSV();

            Assert.NotEmpty(results);
        }
Пример #24
0
 //被修改
 public void SetData(EmailData emailData)
 {
     this.mEmailData = emailData;
     title.text      = emailData.title;
     content.text    = emailData.content;
     getInfo.sprite  = ResourceManager.Instance.GetSpriteByName((int)EAtlasType.EMain, "title_mail_font1");;
 }
Пример #25
0
        protected OperationResult SendEmail(EmailData EMail)
        {
            OperationResult result = new OperationResult();

            try
            {
                bool isValid = EMail != null;//&& validationResults.Count == 0;

                if (isValid)
                {
                    string Subject = EMail.Subject;

                    if (!string.IsNullOrEmpty(this.SubjectPrefix))
                    {
                        Subject = this.SubjectPrefix + Subject;
                    }

                    result = this.EmailHelper.SendEmail(this.EmailHelper.MailSender, this.EmailHelper.MailSenderDisplayName, EMail.Recipient, Subject, EMail.Body, true, null, EMail.AttachmentFileName);
                }

                else
                {
                    throw new Exception("Invalid Email message");
                }
            }

            catch (Exception ex)
            {
                LoggingManager.Instance.SaveErrorLog(ex);
                //MailingManager.Instance.SendErrorEmail(ex);
            }

            return(result);
        }
Пример #26
0
        private Web CreateCompanyEmail(int companyId, EmailData emailData, DbTransaction dbTran)
        {
            var email = _emailFactory.Create(companyId, emailData.Value, emailData.Description);

            _repository.SetWeb(email, isActual: true, dbTran);

            return(email);
        }
Пример #27
0
    private void DisplayEmail(EmailData emailData)
    {
        _emailDetailsPanel.SetActive(true);

        _fromText.text    = emailData.MessageData.from.emailAddress.name;
        _subjectText.text = emailData.MessageData.subject;
        _bodyText.text    = emailData.MessageData.bodyPreview;
    }
Пример #28
0
        public void SendEmail(EmailData data, Dictionary <string, byte[]> attachments)
        {
            UseOverrideEmailDataIfSet(data);

            var client = new EmailServiceClient();

            client.SendEmailWithSimpleAttachments(data, attachments);
        }
Пример #29
0
        public void SendEmail(EmailData data, List <Guid> docGuids)
        {
            UseOverrideEmailDataIfSet(data);

            var client = new EmailServiceClient();

            client.SendEmailWithAttachments(data, docGuids);
        }
Пример #30
0
        public void SendEmail(EmailData data)
        {
            UseOverrideEmailDataIfSet(data);

            var client = new EmailServiceClient();

            client.SendEmail(data);
        }
Пример #31
0
 public EmailData(EmailData baseData, string toAddress)
 {
     ToAddress = toAddress;
     FromAddress = baseData.FromAddress;
     FromDisplayName = baseData.FromDisplayName;
     ReplyToAddress = baseData.ReplyToAddress;
     Subject = baseData.Subject;
     BodyHtml = baseData.BodyHtml;
     BodyText = baseData.BodyText;
 }
        public ActionResult Edit(int id, int emailType)
        {
            var email = new Email();
            var constituentId =  Convert.ToInt32(Session["constituentId"]);
            TryUpdateModel(email);
            email.Type = new EmailType() { Id = emailType };
            email.Constituent = new Constituent { Id = constituentId };
            mapper = new AutoDataContractMapper();
            var emailData = new EmailData();
            mapper.Map(email, emailData);

            HttpHelper.Put(string.Format(serviceBaseUri+"/Emails/{0}",id), emailData);
            return PartialView(new GridModel(GetEmails()));
        }
Пример #33
0
        public void ProcessEmail(EmailData email)
        {
            try
            {
                string message = string.Format(
                    "\u0002\u00035{0} \u00032wrote {3} with subject: \u00035\"{1}\" \u00032and body: \u00035{2}",
                     email.From,
                     email.Subject,
                     email.ContentSummary,
                     ListName);

                _bot.Client.RfcPrivmsg(_bot.Channels[0], message);
            }
            catch (Exception e)
            {
                // :(
            }
        }
Пример #34
0
        private String EncryptInfo()
        {
            IFormatter form = new BinaryFormatter();
            EmailData sd = new EmailData()
            {
                UserName = sUserName,
                EmployerID = empID,
                SSN = sSSN,
                MemberID = sMemberID,
                Expiration = DateTime.Now.AddMinutes(3)
            };

            MemoryStream ser = new MemoryStream();
            form.Serialize(ser, (object)sd);
            ser.Position = 0;

            using (RijndaelManaged rijndaelCipher = new RijndaelManaged())
            {
                PasswordDeriveBytes secretKey = new PasswordDeriveBytes(Encoding.ASCII.GetBytes(sEmployerName), Encoding.ASCII.GetBytes("LetMeReset!"));
                using (ICryptoTransform encryptor = rijndaelCipher.CreateEncryptor(secretKey.GetBytes(32), secretKey.GetBytes(16)))
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
                        {
                            cryptoStream.Write(ser.ToArray(), 0, (int)ser.Length);
                            cryptoStream.FlushFinalBlock();
                            string base64 = Convert.ToBase64String(memoryStream.ToArray());
                            string urlEncoded = Microsoft.Security.Application.Encoder.UrlEncode(base64);
                            return urlEncoded;
                        }
                    }
                }
            }
        }