public void SetEmailType(EmailType type, EmailMessage previousMessage) { this.previousMessage = previousMessage; string addr = previousMessage.sourceAddress; string subj = previousMessage.subject; switch (type) { case EmailType.Reply: case EmailType.ReplyAll: if (addr != null && addr != "") { txtTo.Text = addr; } if (subj != null && subj != "") { txtSubject.Text = subj; } goto case EmailType.Forward; case EmailType.Forward: if (subj != null && subj != "") { txtSubject.Text = subj; } break; } }
public Email(string recipient, EmailType emailTypeToBeSent, string subject, string message) { To.Add(recipient); EmailToBeSent = emailTypeToBeSent; Subject = subject; Message = message; }
/// <summary> /// Given the set of replacement values and a list of property aliases /// of the email fields, construct and send the required emails. /// </summary> /// <param name="emailValues">The replacement values</param> /// <param name="formAliases">The node property aliases, relevant to the current node.</param> protected void ProcessForms(Dictionary<string, string> emailValues, IPublishedContent content, EmailType emailType, params string[] formAliases) { // process each of the given property names, retrieving the form data, // replacing placeholders, and sending the email. foreach (var alias in formAliases) { var prop = content.GetPropertyValue<string>(alias, true, string.Empty); if (prop != null) { var emailFields = DEF_Helper.GetFields(prop); if (emailFields.Send) { ReplacePlaceholders(emailFields, emailValues); emailFields.Body = AddImgAbsolutePath(emailFields.Body); Umbraco.SendEmail( emailFields.SenderEmail, emailFields.SenderName, emailFields.ReceiverEmail, emailFields.Subject, emailFields.Body, emailFields.CCEmail, emailFields.BCCEmail, emailType: emailType ); } } } }
public static string Convert(EmailType EmailType) { string retval=""; switch (EmailType) { case EmailType.ThankYou: retval = "te"; break; case EmailType.Notification: retval = "ne"; break; case EmailType.ASTRO2Notification: retval = "an"; break; case EmailType.ForgotPwd: retval = "fe"; break; case EmailType.Unsubscribe: retval = "ue"; break; default: string err = "Email type \"" + EmailType + "\" is not supported"; Trace.WriteLine(err); throw new ArgumentException(err); } return retval; }
/// <summary> /// /// </summary> /// <param name="type">Type of the new Email Adress</param> /// <param name="address">Email Adress</param> /// <param name="prefered">Is this adressed prefered</param> public Email(EmailType type, string userid, bool prefered) : this() { Type = type; IsPrefered = prefered; UserId = userid; }
private Task SendEmailAsync(EmailType type, ApplicationUser user, string callbackUrl) { var emailModel = new SystemMessage { Name = user.UserName, CallbackUrl = callbackUrl }; return(_emailService.SendAsync(type, emailModel, user.Email)); }
// .........................................................................Add To Queue..................................................................... public void AddToQueue(EmailType emailType, string subject, Recipient recipient, EmailProperties emailProperties) { List <Recipient> recipients = new List <Recipient>(); recipients.Add(recipient); AddToQueue(emailType, subject, recipients, emailProperties); }
private static async Task <string> GetMessage(EmailType type, string username, string generatedString) { string content = await BlobStorageService.GetTextFromFileByName(Enum.GetName(typeof(EmailType), type) + ".html", "email"); content = content.Replace("GENERATED", generatedString); content = content.Replace("USER_NAME", username); return(content); }
public void ParseEmailType_ReturnsCorrectString(EmailType emailType, string expected) { //act var result = EnumFactory.ParseEmailType(emailType); //assert result.Should().Be(expected); }
public void SendReminderMail(int activityId, IQueryable<User> senderList, EmailType emailType, string freeText = "") { var activity = _activityRepository.GetActivityById(activityId); var toAddressToName = senderList.ToDictionary(teamMember => teamMember.Email, teamMember => teamMember.Name); var text = NewEventText(activity, emailType, ""); SendMail(toAddressToName, _emailSettings.From, activity.OrganizingTeam.Name, text.Subject, text.Body); }
public ActionResult DeleteConfirmed(int id) { EmailType emailType = db.EmailTypes.Find(id); db.EmailTypes.Remove(emailType); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool SendEmail(string name, string to, string data, EmailType emailType) { try { string Subject = ""; string HtmlBody = ""; string TextBody = ""; switch (emailType) { case EmailType.subscription: Subject = "Welcome to IBO Virtual"; HtmlBody = GetSubscriptionHtml(name); TextBody = GetSubscriptionText(name); break; case EmailType.resetEmail: Subject = "IBO Virtual Reset Password"; HtmlBody = GetResetMailHtml(name, data); TextBody = GetResetMailText(name, data); break; default: break; } List<Mandrill.Messages.Recipient> recipients = new List<Mandrill.Messages.Recipient>(); Mandrill.Messages.Recipient recipient = new Mandrill.Messages.Recipient(to, name); recipients.Add(recipient); MandrillApi server = new MandrillApi(serverToken); Mandrill.Messages.Message message = new Mandrill.Messages.Message(); message.FromEmail = fromEmail; message.FromName = fromName; message.Subject = Subject; message.Html = HtmlBody; message.Text = TextBody; message.To = recipients.ToArray(); message.TrackOpens = true; MVList<Mandrill.Messages.SendResult> results = server.Send(message); if (results.Count > 0) { Mandrill.Messages.SendResult result = results[0]; if (result.Status == Mandrill.Messages.Status.Sent) { return true; } else { return false; } } } catch { } return false; }
/// <summary> /// Sends an email type that has defined/configured recipients /// </summary> /// <param name="email">The implementation of the IEmail interface</param> /// <param name="type">The type of email being sent</param> /// <param name="cc">Who gets copied on the email</param> /// <param name="subject">Subject of the email</param> /// <param name="content">Email body</param> /// <returns>True if send seems to be successful, false otherwise</returns> public static Task <bool> SendAsync( IEmail email, EmailType type, string cc, string subject, string content) => SendAsync(email, type, null, new List <string> { cc }, subject, content);
private void SendEmail(IGrouping <byte, busSagEmployee> lbussagemployee, EmailType eemtMailType) { string lstrAddresse = "Dear "; string[] lstrEmailToAddresses = null; lstrAddresse += string.Join(",", lbussagemployee.Select(emp => emp.firstName)); lstrEmailToAddresses = lbussagemployee.Select(emp => emp.email)?.ToArray(); string lstrFromAddresses = ConfigurationManager.AppSettings["EmailFromAddress"]?.ToString(); string lstrOccasion = string.Empty; string lstrSubject = string.Empty; switch (eemtMailType) { case EmailType.JoiningEmail: lstrSubject = ConfigurationManager.AppSettings["JoiningEmailSubject"]?.ToString(); if (string.IsNullOrEmpty(lstrSubject)) { lstrSubject = "Welcome To Sagitec Family"; } lstrOccasion = lstrSubject; break; case EmailType.BirthDayEmail: lstrSubject = ConfigurationManager.AppSettings["BirthDayEmailSubject"]?.ToString(); if (string.IsNullOrEmpty(lstrSubject)) { lstrSubject = "Happy Birth Day"; } lstrOccasion = lstrSubject; break; case EmailType.BelatedBirthDayEmail: lstrSubject = ConfigurationManager.AppSettings["BelatedBirthDayEmailSubject"]?.ToString(); if (string.IsNullOrEmpty(lstrSubject)) { lstrSubject = "Belated Happy Birth Day"; } lstrOccasion = lstrSubject; break; case EmailType.JoiningAnniversary: lstrSubject = ConfigurationManager.AppSettings["JoiningAnniversaryEmailSubject"]?.ToString(); if (string.IsNullOrEmpty(lstrSubject)) { lstrSubject = "Happy Anniversary"; } lstrOccasion = lstrSubject; break; default: break; } if (SendMail(lstrFromAddresses, lstrEmailToAddresses, lstrSubject, lstrOccasion, lstrAddresse)) { UpdateJoiBirAnniValues(lbussagemployee, eemtMailType); } }
private void CreateEmailType(string name, string description) { var emailType = EmailType.SingleOrDefault(x => x.Name == name) ?? new EmailType(); emailType.Deleted = false; emailType.Name = name; emailType.Description = description; emailType.Save(); }
public async Task <ActionResult> DeleteConfirmed(int id) { EmailType emailtype = await db.EmailTypes.FindAsync(id); db.EmailTypes.Remove(emailtype); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public Email(string content, string subject, Sender sender, EmailType type, BlindCarbonCopy bcc = null) { Id = Guid.NewGuid(); Content = content; Sender = sender; Subject = subject; Type = type; Bcc = bcc; }
public async Task <IRestResponse> SendContactRequestAsync(EmailType emailType, string userEmail, string userComment) { IRestResponse response = null; response = await SendMailAsync(emailType, userEmail, MailGunMessages.From_Support, "User question", userComment); return(response); }
private void SendNotificationEmail(EmailType type, bool isOwner, OrderDetailModel order) { switch (type) { case EmailType.PICKUP_REMINDER: if (isOwner) { NotifyMailer.OwnerPickupReminder(order.Item.Owner.Email, order).Send(); break; } else { NotifyMailer.RenterPickupReminder(order.Order.User.Email, order).Send(); break; } case EmailType.RETURN_REMINDER: if (isOwner) { NotifyMailer.OwnerReturnReminder(order.Item.Owner.Email, order).Send(); break; } else { NotifyMailer.RenterReturnReminder(order.Order.User.Email, order).Send(); break; } case EmailType.ORDER_TERMINATED: if (isOwner) { NotifyMailer.OwnerOrderTerminated(order.Item.Owner.Email, order).Send(); break; } else { NotifyMailer.RenterOrderTerminated(order.Order.User.Email, order).Send(); break; } case EmailType.ORDER_CLOSED: if (isOwner) { NotifyMailer.OwnerOrderClosed(order.Item.Owner.Email, order).Send(); break; } else { NotifyMailer.RenterOrderClosed(order.Order.User.Email, order).Send(); break; } default: break; } }
/// <summary> /// 创建邮件发送类 /// 发送人授权码通常获取方式为: /// 进入邮箱设置界面 -> 找到POP3/SMTP/IMAP设置 -> 开启POP3/SMTP/IMAP服务 -> 附近可找到授权码(通常叫做客户端授权码) /// </summary> /// <param name="fromemail">发送人邮箱</param> /// <param name="toemail">接收人邮箱</param> /// <param name="authorization">发送人授权码</param> /// <param name="emailtype">发送人邮箱类型</param> public EmailHelper(string fromemail, string authorization, EmailType emailtype) { this.fromemail = fromemail; this.authorization = authorization; this.emailtype = emailtype; switch (emailtype) { case EmailType.QQ_PERSONAL_EMIAL: host = "smtp.qq.com"; break; case EmailType.QQ_EENTERPRISE_EMAIL: host = "smtp.exmail.qq.com"; break; case EmailType.NETEASE_MAIL: host = "smtp.163.com"; break; case EmailType.EMAIL_126: host = "smtp.126.com"; break; case EmailType.SINA_EMAIL: host = "smtp.sina.cn"; break; case EmailType.EMAIL_21CN: host = "smtp.21cn.com"; break; case EmailType.SOHU_EMAIL: host = "smtp.sohu.com"; break; case EmailType.HOTMAIL: host = "smtp.live.com"; break; case EmailType.EMAIL_139: host = "smtp.139.com"; break; case EmailType.JINGAN_EMAIL: host = "smtp.zzidc.com"; break; case EmailType.ALIYUAN_EMAIL: host = "smtp.mxhichina.com"; break; default: host = null; break; } }
public static string GenerateHTMLBody(EmailType type) { ConfigurationProcess configProcess = new ConfigurationProcess(); XmlConfigurator.Configure(); try { string tempData = string.Empty; string header = configProcess.GetConfigurationByID(Common.FASTConstant.CONFIG_EMAILHEADER).Value; string footer = configProcess.GetConfigurationByID(Common.FASTConstant.CONFIG_EMAILFOOTER).Value; string adminEmail = configProcess.GetConfigurationByID(Common.FASTConstant.CONFIG_ADMINEMAIL).Value; string adminTel = configProcess.GetConfigurationByID(Common.FASTConstant.CONFIG_ADMINTEL).Value; switch (type) { case EmailType.REGISTRATION: tempData = GetTemplate("Registration.html"); break; case EmailType.CHANGE_PASSWORD: tempData = GetTemplate("ChangePassword.html"); break; case EmailType.RESET_PASSWORD: tempData = GetTemplate("ResetPassword.html"); break; case EmailType.BULK_UPLOAD: tempData = GetTemplate("BulkUploadResult.html"); break; default: return(String.Empty); } if (!String.IsNullOrEmpty(tempData)) { tempData = tempData.Replace(Common.FASTConstant.EMAIL_HEADER, header) .Replace(Common.FASTConstant.EMAIL_FOOTER, footer) .Replace(Common.FASTConstant.EMAIL_APPADMIN_EMAIL, adminEmail) .Replace(Common.FASTConstant.EMAIL_APPADMIN_TELNO, adminTel); } else { tempData = string.Empty; } return(tempData); } catch (Exception ex) { tracer.Error(ex.ToString()); return(String.Empty); } }
public ActionResult Edit(EmailType emailtype) { if (ModelState.IsValid) { db.Entry(emailtype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emailtype)); }
public JsonResult IsRead(int id) { EmailType obj = GetById(id); if (obj.IsReply != 0) { return(Json(new { Msg = 1 }, JsonRequestBehavior.AllowGet)); } return(Json(new { Msg = 0 }, JsonRequestBehavior.AllowGet)); }
public async Task <IRestResponse> SendResetPasswordEmailAsync(EmailType emailType, String toAddress, String userName, String callbackURL) { IRestResponse response = null; response = await SendMailAsync(emailType, MailGunMessages.From_Support, toAddress, MailGunMessages.Subject_ResetPassword, String.Format(MailGunMessages.Message_ResetPassword, userName) + String.Format(MailGunMessages.Action_ResetPassword, callbackURL) + MailGunMessages.Email_Signature); return(response); }
//[Display(Name = Resources.EmailConfigurationsConstants.OccupyThreadEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool OccupyThreadEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.GiveUpEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool GiveUpEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.ReportIssueEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool ReportIssueEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.PriceProposalEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool PriceProposalEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.ThreadMoreDetailsEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool ThreadMoreDetailsEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.ThreadNewPostEmailToUser, ResourceType = typeof(Resources.EmailConfigurations))] //public bool ThreadNewPostEmailToUser { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.DirectQuestionEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool DirectQuestionEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.ThreadAnswerAcceptedEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool ThreadAnswerAcceptedEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.PaymentAnswerEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool PaymentAnswerEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.ThreadNewPostEmailToExpert, ResourceType = typeof(Resources.EmailConfigurations))] //public bool ThreadNewPostEmailToExpert { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.AdditionalServiceEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool AdditionalServiceEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.AdditionalServiceAnswerEmail, ResourceType = typeof(Resources.EmailConfigurations))] //public bool AdditionalServiceAnswerEmail { get; set; } //[Display(Name = Resources.EmailConfigurationsConstants.Newsletter, ResourceType = typeof(Resources.EmailConfigurations))] //public bool Newsletter { get; set; } public static MailConfigurationForm Create(EmailType selectedValues, EmailRecipientType recipientTypes) { var configuration = new MailConfigurationForm { RecipientTypes = recipientTypes, SelectedEmails = new Dictionary<EmailType, bool>() }; var emailTypes = EmailMetadataHelper.GetTypesForRecipientType(recipientTypes); foreach (var emailType in emailTypes) configuration.SelectedEmails.Add(emailType, selectedValues.HasFlag(emailType)); return configuration; }
public static EmailAddress New(EmailType type, string address, bool mailingList) { var obj = new EmailAddress { EmailType = type, Address = address, MailingList = mailingList, }; return(obj); }
public void SendMail(int activityId, EmailType emailType, string freeText = "") { var activity = _activityRepository.GetActivityById(activityId); var teamId = activity.OrganizingTeam.Id; var teamMembers = _teamRepository.GetTeamMembers(teamId); var toAddressToName = teamMembers.ToDictionary(teamMember => teamMember.Email, teamMember => teamMember.Name); var text = NewEventText(activity, emailType, freeText); SendMail(toAddressToName, _emailSettings.From, activity.OrganizingTeam.Name, text.Subject, text.Body); }
public EmailHelper(string name, string password, EmailType type) : this(name, password) { switch (type) { case EmailType.Gmail: SmtpClient.Port = 587; SmtpClient.EnableSsl = true; break; } }
/// <summary> /// 创建 SmtpHelper 实例 /// </summary> /// <param name="type">Email类型</param> /// <param name="enableSsl">指定 SmtpClient 是否使用安全套接字层 (SSL) 加密连接。</param> /// <param name="credential">设置用于验证发件人身份的凭据。</param> public SmtpHelper(EmailType type, bool enableSsl, NetworkCredential credential) { MailValidatorHelper.ValideArgumentNull <NetworkCredential>(credential, "credential"); this.EmailTypeConfig(type, enableSsl); SmtpClient.UseDefaultCredentials = false; SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpClient.Credentials = credential; SmtpClient.Timeout = 100000; }
/// <summary> /// 获取用户账户信息 /// </summary> /// <param name="type">邮件类型</param> /// <returns>用户账户信息</returns> /// <remarks>2014-1-14 黄波 创建</remarks> private FocusUser GetFocusUser(EmailType type) { FocusUser user = new FocusUser(); EmailSenderInfo sender = EmailSender.GetSenderByType(type); user.Email = sender.Email; user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile("hytHYTedm", FormsAuthPasswordFormat.SHA1.ToString("G")); return(user); }
private static MailMessage InitialiseMailMessage(EmailType emailType) { var msgObj = new MailMessage(); msgObj.From = new MailAddress("*****@*****.**"); msgObj.IsBodyHtml = false; msgObj.Subject = SetEmailSubject(emailType); return(msgObj); }
{//Install before building project //Install-Package EntityFramework -Version 6.3.0 //In the App.config Add your Connection String and the the name that was use in the base() DataBaseContext.cs Contex folder //To Seed the data base with a file record add firstName , lastName ,emailAddress,emailType //When building the app the code will create the database static void Main(string[] args) { string firstName = "C"; string lastName = "Alas"; string emailAddress = "*****@*****.**"; EmailType emailType = EmailType.Personal; Seed(firstName, lastName, emailAddress, emailType); }
public async Task <EmailType> Get(long Id) { EmailType EmailType = await UOW.EmailTypeRepository.Get(Id); if (EmailType == null) { return(null); } return(EmailType); }
public Customer_EmailTypeDTO(EmailType EmailType) { this.Id = EmailType.Id; this.Code = EmailType.Code; this.Name = EmailType.Name; this.Errors = EmailType.Errors; }
public static String FormatEmail <T>(Theme theme, EmailType type, IDictionary <String, T> replaces, Misc misc) { return(PlainText.Html[theme, type, misc] .Format( replaces.ToDictionary( p => p.Key, p => p.Value?.ToString() ) )); }
/// <summary> /// 创建 SmtpHelper 实例 /// </summary> /// <param name="type">Email类型</param> /// <param name="enableSsl">指定 SmtpClient 是否使用安全套接字层 (SSL) 加密连接。</param> /// <param name="userName">用户名</param> /// <param name="password">密码</param> public SmtpHelper(EmailType type, bool enableSsl, string userName, string password) { MailValidatorHelper.ValideStrNullOrEmpty(userName, "userName"); MailValidatorHelper.ValideStrNullOrEmpty(password, "password"); this.EmailTypeConfig(type, enableSsl); SmtpClient.UseDefaultCredentials = false; SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpClient.Credentials = new NetworkCredential(userName, password); SmtpClient.Timeout = 100000; }
public async Task <Email> GetEmail(EmailType type, Guid chapterId) { ChapterEmail chapterEmail = await GetChapterEmail(chapterId, type); if (chapterEmail != null) { return(new Email(chapterEmail.Type, chapterEmail.Subject, chapterEmail.HtmlContent)); } return(await GetEmail(type)); }
public static string GetMailName(EmailType type) { if (type == EmailType.Empty) { return(""); } else { return("*****@*****.**"); } }
public Email GetEmailAddress(EmailType type) { foreach (Email email in GetEmailAddresses()) { if (email.Type == type) { return(email); } } return(null); }
public ActionResult Create(EmailType emailtype) { if (ModelState.IsValid) { db.EmailTypes.Add(emailtype); db.SaveChanges(); return RedirectToAction("Index"); } return View(emailtype); }
public virtual MvcMailMessage Message(IMailModel model, EmailType type) { ViewData.Model = model; return Populate(x => { x.BodyEncoding = Encoding.UTF8; x.IsBodyHtml = true; x.Subject = model.Subject; x.ViewName = type.ToString(); x.To.Add(model.ReceiverEmail); }); }
public string EmailTemplate(string to, string content,EmailType emailType) { string templatePath = string.Empty; if (emailType == EmailType.Activation) { templatePath = AppConstants.EmailActivationTemplatePath; } using (var sr = File.OpenText(HttpContext.Current.Server.MapPath(templatePath))) { var sb = sr.ReadToEnd(); sr.Close(); return string.Empty; } }
public Email(string to, string from, string cc, string subject, string body, bool isHtml, EmailType type) { _to = to; _from = from; _cc = cc; _subject = subject; _body = body; _isHtml = isHtml; _isForceSend = false; _sendAttempt = 0; _type = type; _isSent = false; _submitTime = DateTime.UtcNow; _sendTime = null; }
public static string ParseEmailType(EmailType emailAddressType) { switch (emailAddressType) { case EmailType.Unknown: return "Unknown"; case EmailType.Personal: return "Personal"; case EmailType.Company: return "Company"; case EmailType.ThirdParty: return "Third Party"; default: return string.Empty; } }
public static void SendEmailBase(string title, string content, EmailType emailType, string emailTo) { MailMessage message = new MailMessage(); string mailFrom = ""; //设置优先级 message.Priority = MailPriority.Normal; //接收方 message.To.Add(emailTo); //标题 message.Subject = title + "—宅食府(zhaishifu.com)"; message.SubjectEncoding = Encoding.GetEncoding("gb2312"); //邮件正文是否支持HTML message.IsBodyHtml = true; //正文编码 message.BodyEncoding = Encoding.GetEncoding("gb2312"); message.Body = content; //实例化SmtpClient SmtpClient client = new SmtpClient("smtp.exmail.qq.com", 25); //出站方式设置为NetWork client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = false; //smtp服务器验证并制定账号密码 switch (emailType) { case EmailType.ResetPassword: mailFrom = "*****@*****.**"; client.Credentials = new NetworkCredential(mailFrom, "jin4828466"); break; case EmailType.SystemErrorInfo: mailFrom = "*****@*****.**"; client.Credentials = new NetworkCredential(mailFrom, "jin_4828466"); break; } //设置收件方看到的邮件来源为:发送方邮件地址、来源标题、编码 message.From = new MailAddress(mailFrom, "宅食府", Encoding.GetEncoding("gb2312")); client.Send(message); }
private string GetEmailFilePath(EmailType type) { emailMessageType = type; switch (type) { case EmailType.Confirmation: emailMessageHtml = HTML_CONFIRMATION; break; case EmailType.Forgotten: emailMessageHtml = HTML_FORGOTEN; break; case EmailType.Welcome: emailMessageHtml = HTML_WELCOME; break; case EmailType.Default: emailMessageHtml = HTML_DEFAULT; break; default: emailMessageHtml = ""; break; } return emailMessageHtml; }
private string GetEmailBody(string firstName, string lastName, Guid guid, EmailType type, string rankingText) { #region Build Email Header & Footer string siteAdminFullName = _siteAdminInfoDict[ConfigEnum.SiteMasterFirstName] + " " + _siteAdminInfoDict[ConfigEnum.SiteMasterLastName]; string contactFullName = firstName + " " + lastName; string emailHeader = String.Format(_emailHeaderTemplate, contactFullName); string emailFooter = String.Format(_emailFooterTemplate, siteAdminFullName, _siteAdminInfoDict[ConfigEnum.SiteMasterEmail], contactFullName, _siteAdminInfoDict[ConfigEnum.SiteMasterPhone]); #endregion #region Build Email Body string body = String.Empty; switch (type) { case EmailType.ProjectSubmit: string project=""; using(MatchingDB db = new MatchingDB()) { project=db.Projects.Where(p=>p.Guid==guid).FirstOrDefault().Name; } body = String.Format(PROJECT_SUBMIT_BODY, project, rankingText); break; case EmailType.StudentSubmit: body = String.Format(STUDENT_SUBMIT_BODY, rankingText); break; default: break; } #endregion string message = emailHeader + body + emailFooter; return message; }
public EmailService(EmailType EmailType, IMessageModel Message) { CurrEmailType = EmailType; this.Message = Message; }
public EmailBuilder WithType(EmailType type) { email.Type = type; return this; }
/// <summary> /// Constructor to set subject and body sections of e-mail to the system generated values using pre-set e-mail templates. Used when system-generated notification e-mails are to be used to notify contacts. /// Usage: EmailQueueService.EmailQueueMessage(new Contact(<Project|Student>),EmailType.<Project|Student>); /// </summary> /// <param name="type">Type of email template that will be use to generate system generated e-mail subject and body</param> public EmailQueueMessage(Contact contact, EmailType type) : this(contact.Id, contact.ContactType.ToString(), contact.FirstName, contact.LastName, contact.Guid, contact.Email) { Subject = GetEmailSubject(type); Body = GetEmailBody(contact.FirstName, contact.LastName, contact.Guid, type); }
public Email GetEmailAddress(EmailType type) { foreach (Email email in GetEmailAddresses()) { if (email.Type == type) return email; } return null; }
private bool SendMessage(string to, string param, EmailType messageType) { bool result = false; string username = "******"; string password = "******"; try { foreach (string line in File.ReadAllLines("Plugins\\EmailPluginFiles\\credentials.ini")) { if (line.StartsWith("username="******"password="******"Message from " + username; mailMessage.Body = param; } else if (messageType == EmailType.File) { mailMessage.Subject = "File from " + username; FileInfo fileInfo = new FileInfo(param); mailMessage.Body = "File Name = " + fileInfo.FullName + "\n" + "File Size = " + (fileInfo.Length / 1024) + " KB\n"; Attachment file = new Attachment(param); mailMessage.Attachments.Add(file); } else { throw new ArgumentException("invalid args"); } SmtpClient mailClient = new SmtpClient("imap.gmail.com", 587); mailClient.UseDefaultCredentials = false; mailClient.EnableSsl = true; mailClient.Credentials = credentials; //this is a workaround for the certificate errors with gmail! dono why i dont have the real certs... ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(RemoteServerCertificateValidationCallback); mailClient.Send(mailMessage); result = true; } catch (Exception ex) { lastError = ex.Message; result = false; } return result; }
public EmailQueueMessage(Contact contact, EmailType type, string rankingText, params string[] receipents) : this(contact.Id, contact.ContactType.ToString(), contact.FirstName, contact.LastName, contact.Guid, receipents) { Subject = GetEmailSubject(type); Body = GetEmailBody(contact.FirstName, contact.LastName, contact.Guid, type, rankingText); }
/// <summary> /// Returns string representation of the EmailType enum constant. /// </summary> /// <param name="emailType">EmailType enum constant</param> public static string GetEmailTypeString(EmailType emailType) { // Get a enum representation and return it as result switch (emailType) { case EmailType.General: return "general"; case EmailType.Blog: return "blog"; case EmailType.Boards: return "boards"; case EmailType.BookingEvent: return "bookingevent"; case EmailType.Ecommerce: return "ecommerce"; case EmailType.EcommerceEproductExpiration: return "ecommerceeproductexpiration"; case EmailType.Forum: return "forum"; case EmailType.ForumSubscribtion: return "forumsubscribtion"; case EmailType.Friends: return "friends"; case EmailType.GroupMember: return "groupmember"; case EmailType.GroupInvitation: return "groupinvitation"; case EmailType.GroupMemberInvitation: return "groupmemberinvitation"; case EmailType.Password: return "password"; case EmailType.ProjectManagement: return "projectmanagement"; case EmailType.Messaging: return "messaging"; case EmailType.Registration: return "registration"; case EmailType.RegistrationApproval: return "registrationapproval"; case EmailType.MembershipRegistration: return "membershipregistration"; case EmailType.MembershipExpiration: return "membershipexpiration"; case EmailType.ForgottenPassword: return "forgottenpassword"; case EmailType.Newsletter: return "newsletter"; case EmailType.Workflow: return "workflow"; case EmailType.MembershipChangePassword: return "membershipchangepassword"; case EmailType.Scoring: return "scoring"; default: return "general"; } }
private string GetEmailBody(string firstName, string lastName,Guid guid,EmailType type) { #region Build Email Header & Footer string siteAdminFullName = _siteAdminInfoDict[ConfigEnum.SiteMasterFirstName] + " " + _siteAdminInfoDict[ConfigEnum.SiteMasterLastName]; string contactFullName = firstName + " " + lastName; string emailHeader = String.Format(_emailHeaderTemplate, contactFullName); string emailFooter = String.Format(_emailFooterTemplate, siteAdminFullName, _siteAdminInfoDict[ConfigEnum.SiteMasterEmail], contactFullName, _siteAdminInfoDict[ConfigEnum.SiteMasterPhone]); #endregion #region Build Email Body string body = String.Empty; switch (type) { case EmailType.ProjectAccess: body = String.Format(PROJECT_URL_EMAIL_BODY, UrlHelper.GetAccessUrlForTheUser(guid, UrlType.Project)); break; case EmailType.StudentAccess: body = String.Format(STUDENT_URL_EMAIL_BODY, UrlHelper.GetAccessUrlForTheUser(guid, UrlType.Student)); break; default: break; } #endregion string message = emailHeader + body + emailFooter; return message; }
/// <summary> /// Returns appropriate resolver for given e-mail type. /// </summary> /// <param name="type">E-mail type</param> public static ContextResolver GetEmailTemplateResolver(EmailType type) { switch (type) { case EmailType.Blog: return BlogsResolver; case EmailType.Boards: return BoardsResolver; case EmailType.BookingEvent: return BookingResolver; case EmailType.Ecommerce: return EcommerceResolver; case EmailType.EcommerceEproductExpiration: return EcommerceEproductExpirationResolver; case EmailType.Forum: return ForumsResolver; case EmailType.ForumSubscribtion: return ForumsSubscribtionResolver; case EmailType.Friends: return FriendsResolver; case EmailType.GroupMember: return GroupMemberResolver; case EmailType.GroupInvitation: return GroupsInvitationResolver; case EmailType.GroupMemberInvitation: return GroupsAcceptedInvitationResolver; case EmailType.Password: return PasswordResolver; case EmailType.ProjectManagement: return ProjectManagement; case EmailType.Messaging: return MessagingResolver; case EmailType.Registration: return RegistrationResolver; case EmailType.RegistrationApproval: return RegistrationApprovedResolver; case EmailType.MembershipRegistration: return MembershipRegistrationResolver; case EmailType.MembershipExpiration: return MembershipExpirationResolver; case EmailType.ForgottenPassword: return ForgottenPasswordResolver; case EmailType.Newsletter: return NewsletterResolver; case EmailType.Workflow: return WorkflowResolver; case EmailType.Scoring: return ScoringResolver; case EmailType.MembershipChangePassword: return MembershipChangePasswordResolver; default: return EmailTemplateResolver; } }
private string GetEmailSubject(EmailType type) { string subject=null; switch (type) { case EmailType.ProjectAccess: subject = PROJECT_URL_EMAIL_SUBJECT; break; case EmailType.StudentAccess: subject = STUDENT_URL_EMAIL_SUBJECT; break; case EmailType.ProjectSubmit: subject = PROJECT_SUBMIT_SUBJECT; break; case EmailType.StudentSubmit: subject = STUDENT_SUBMIT_SUBJECT; break; default: break; } return subject; }
private EmailType GetOtherEmailByParameters(string ebayAccount, DateTime createTime, string sortStr) { EmailType ce = null; DateTime limitTime = DateTime.Now.AddDays(-90); if (createTime < limitTime) { createTime = limitTime; } string sqlParam = " AND SaleAccount IN(" + ebayAccount + ")"; if (sortStr == "PRE") { sqlParam += " AND [CreateOn] > '" + createTime + "' ORDER BY [CreateOn] ASC"; } else if (sortStr == "NEXT") { sqlParam += " AND [CreateOn] < '" + createTime + "' ORDER BY [CreateOn] DESC"; } string sql = "SELECT TOP 1 * FROM [Email] WHERE [MessageStatus] ='Unanswered'" + sqlParam; List<EmailType> result = EmailType.findBySql(sql); foreach (EmailType e in result) { ce = e; break; } return ce; }
protected void Page_Load(object sender, EventArgs e) { strId = Request.QueryString["id"]; currentEbayAccount = Request.QueryString["ea"]; if (string.IsNullOrEmpty(strId)) { Response.Write("<script language='javascript' type='text/javascript'>alert('非法访问!');location.href='Default.aspx';</script>"); return; } ce = EmailType.findById(int.Parse(strId)); if (ce.MessageStatus == "Replied") { Page.ClientScript.RegisterStartupScript(typeof(Page), "", "<script language='javascript' type='text/javascript'>alert('该Email已回复!');EmailListReload();</script>"); return; } List<OrderType> listOrder = OrderType.find("BuyerId='" + ce.BuyerAccount + "' and UserNameForm='" + ce.SaleAccount + "' and CreateOn>'" + DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd") + "'").list(); for (int i = 0; i < listOrder.Count; i++) { listOrder[i].OrderGoods = OrderGoodsType.find("OrderNo='" + listOrder[i].Id + "'").list(); } rpOrderInfo.DataSource = listOrder; rpOrderInfo.DataBind(); DateTime limitTime = DateTime.Now.AddDays(-90); DataTable dtHistory = db.RunTable<EmailType>("SELECT E.BuyerAccount,E.[Subject],E.[Body],E.[CreateOn],RE.[Replier],RE.[Subject],RE.[Body],RE.CreateOn FROM [Email] AS E LEFT JOIN [EmailReplied] AS RE ON E.MessageID = RE.MessageID WHERE E.BuyerAccount='" + ce.BuyerAccount + "' AND E.SaleAccount='" + ce.SaleAccount + "' AND E.CreateOn>'" + limitTime + "' ORDER BY E.CreateOn ASC"); List<EmailRepliedType> result = new List<EmailRepliedType>(); foreach (DataRow dr in dtHistory.Rows) { EmailRepliedType re = new EmailRepliedType(); re.Replier = dr[0].ToString(); re.Subject=dr[1].ToString(); re.Body = dr[2].ToString(); re.CreateOn = DateTime.Parse(dr[3].ToString()); re.IsToEbay = false; result.Add(re); re = new EmailRepliedType(); if (!dr.IsNull(4)) { re.Replier = dr[4].ToString(); re.Subject = dr[5].ToString(); re.Body = dr[6].ToString(); re.CreateOn = DateTime.Parse(dr[7].ToString()); re.IsToEbay = true; result.Add(re); } } rpHistoryEmail.DataSource = result; rpHistoryEmail.DataBind(); lblOurStore.Text = ce.SaleAccount; lblItemCurrency.Text = ce.ItemPriceCurrency; lblItemTitle.Text = ce.ItemTitle; lblItemValue.Text = ce.ItemPrice.ToString(); lblMsgType.Text = ce.MessageType; lblSenderEmail.Text = ce.BuyerEmail.Replace("@", " @"); hlinkViewItem.NavigateUrl = ce.ItemURL; hlinkViewItem.Target = "_blank"; txtEmailTitle.Text = ce.Subject; hdStartTime.Value = DateTime.Now.ToString(); }
/// <summary> /// The method is used to send a mail /// </summary> /// <param name="emailType">The type of the email.</param> /// <param name="subject">The subject of the mail.</param> /// <param name="body">The body of the item.</param> protected void SendEmail(EmailType emailType, string subject, string body) { SendMailRequest request = new SendMailRequest { RequestData = { ClientId = Guid.NewGuid().ToString("N"), Mime = TestSuiteHelper.CreateMIME( emailType, Common.GetMailAddress(this.User1Information.UserName, this.User1Information.UserDomain), Common.GetMailAddress(this.User2Information.UserName, this.User2Information.UserDomain), subject, body) } }; SendMailResponse sendMailResponse = this.ASAIRSAdapter.SendMail(request); this.Site.Assert.AreEqual<string>( string.Empty, sendMailResponse.ResponseDataXML, "The server should return an empty XML body to indicate SendMail command is executed successfully."); this.SwitchUser(this.User2Information, true); this.RecordCaseRelativeItems(this.User2Information.UserName, this.User2Information.InboxCollectionId, subject); }