/// <summary> /// 用指定的编码发 /// </summary> /// <param name="encoding">编码</param> public void SendToEMail() { System.Net.Mail.MailMessage MM = new System.Net.Mail.MailMessage(FromEmail, ToEmail, Subject, Content); MM.Priority = System.Net.Mail.MailPriority.High; MM.IsBodyHtml = IsHtml; MM.BodyEncoding = Encoding; String sendUser; int s = FromEmail.IndexOf('<'); int e = FromEmail.IndexOf('>'); if (s > 0 && e > 0) { FromEmail = FromEmail.Substring(s + 1, e - s - 1); } String[] EmailParts = FromEmail.Split("@".ToCharArray(), 2); sendUser = EmailParts[0]; SmtpClient SC = new SmtpClient(SmtpServer, ServerPort); SC.DeliveryMethod = SmtpDeliveryMethod.Network; SC.Timeout = 100000; SC.Credentials = new System.Net.NetworkCredential(sendUser, FromEmailPwd); SC.Send(MM); }
public override int GetHashCode() { unchecked { var hashCode = WebApp != null?WebApp.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Hosts != null ? Hosts.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ToEmail != null ? ToEmail.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FromEmail != null ? FromEmail.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ServicePlanResourceGroup != null ? ServicePlanResourceGroup.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SiteSlotName != null ? SiteSlotName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GroupName != null ? GroupName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WebAppEnvironmentParams != null ? WebAppEnvironmentParams.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureDnsEnvironmentParams != null ? AzureDnsEnvironmentParams.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureDnsZoneName != null ? AzureDnsZoneName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureDnsRelativeRecordSetName != null ? AzureDnsRelativeRecordSetName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GoDaddyDnsEnvironmentParams != null ? GoDaddyDnsEnvironmentParams.GetHashCode() : 0); hashCode = (hashCode * 397) ^ UseIpBasedSsl.GetHashCode(); hashCode = (hashCode * 397) ^ RsaKeyLength; hashCode = (hashCode * 397) ^ (AcmeBaseUri != null ? AcmeBaseUri.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WebRootPath != null ? WebRootPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ RenewXNumberOfDaysBeforeExpiration; hashCode = (hashCode * 397) ^ (AuthenticationUri != null ? AuthenticationUri.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureTokenAudience != null ? AzureTokenAudience.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureManagementEndpoint != null ? AzureManagementEndpoint.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AzureDefaultWebsiteDomainName != null ? AzureDefaultWebsiteDomainName.GetHashCode() : 0); return(hashCode); } }
public void SendToEmailOld() { System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage(); message.Subject = Subject; message.BodyFormat = IsHtml ? MailFormat.Html : MailFormat.Text; // 设置邮件正文为html 格式 message.BodyEncoding = Encoding; message.Body = Content; // 设置邮件内容 message.From = FromEmail; message.To = ToEmail; String sendUser; int s = FromEmail.IndexOf('<'); int e = FromEmail.IndexOf('>'); if (s > 0 && e > 0) { FromEmail = FromEmail.Substring(s + 1, e - s - 1); } String[] EmailParts = FromEmail.Split("@".ToCharArray(), 2); sendUser = EmailParts[0]; message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //设置服务器需要身份验证 message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", sendUser); //设置用户名 message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", FromEmailPwd); //设置密码 SmtpMail.SmtpServer = SmtpServer; SmtpMail.Send(message); //发送邮件。 }
public ActionResult DeleteConfirmed(int id) { FromEmail fromEmail = db.FromEmails.Find(id); db.FromEmails.Remove(fromEmail); db.SaveChanges(); return(RedirectToAction("Index")); }
private string GetOriginalFrom(int ReturnQuery) { if (Subject.Contains("Fwd:") && OriginalBody.Contains("From:")) { int fromPos = OriginalBody.IndexOf("From:") + 6; int lessThanPos = OriginalBody.IndexOf("<", fromPos); int greaterThanPos = OriginalBody.IndexOf(">", lessThanPos); string from = OriginalBody.Substring(fromPos, lessThanPos - fromPos - 1); string fromEmail = OriginalBody.Substring(lessThanPos + 1, greaterThanPos - lessThanPos - 1); string fromFirstName = ""; string fromLastName = ""; from = from.Trim(); int count = 0; foreach (string item in from.Split(' ')) { if (count == 0) { fromFirstName = item; } else { fromLastName = fromLastName + item; } count++; } if (ReturnQuery == 0) { return(fromFirstName.Trim()); } else if (ReturnQuery == 1) { return(fromLastName.Trim()); } else { return(fromEmail.Trim()); } } else { if (ReturnQuery == 0) { return(FromFirstName.Trim()); } else if (ReturnQuery == 1) { return(FromLastName.Trim()); } else { return(FromEmail.Trim()); } } }
public ActionResult Edit([Bind(Include = "ID,Name,Email")] FromEmail fromEmail) { if (ModelState.IsValid) { db.Entry(fromEmail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fromEmail)); }
public ActionResult Create([Bind(Include = "ID,Name,Email")] FromEmail fromEmail) { if (ModelState.IsValid) { db.FromEmails.Add(fromEmail); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fromEmail)); }
// GET: FromEmails/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FromEmail fromEmail = db.FromEmails.Find(id); if (fromEmail == null) { return(HttpNotFound()); } return(View(fromEmail)); }
/// <summary> /// Converts this Notification to a <see cref="System.Net.Mail.MailMessage">MailMessage</see>. /// </summary> /// <returns><see cref="System.Net.Mail.MailMessage">MailMessage</see></returns> public MailMessage ToMailMessage() { MailMessage message = new MailMessage { Subject = EmailSubject, Body = EmailBody, IsBodyHtml = IsHtml }; if (!string.IsNullOrEmpty(ReplyToEmail)) { MailAddress replyToEmail = new MailAddress(ReplyToEmail, ReplyToEmail); message.ReplyToList.Add(replyToEmail); } if (FromEmail != null) { message.From = FromEmail.ToMailAddress(); } foreach (var address in ToAddresses) { message.To.Add(address.ToMailAddress()); } if (CcAddresses != null && CcAddresses.Count > 0) { foreach (var address in CcAddresses) { message.CC.Add(address.ToMailAddress()); } } if (BccToAddresses != null && BccToAddresses.Count > 0) { foreach (var address in BccToAddresses) { message.Bcc.Add(address.ToMailAddress()); } } if (Attachments != null && Attachments.Count > 0) { foreach (var attachment in Attachments) { message.Attachments.Add(attachment.ToMailAttachment()); } } return(message); }
public void UpdateMailSettings() { SqlHelpers.Update(SqlStatements.SQL_UPDATE_MAIL_SETTINGS.FormatWith(MailServer.FixSqlString(), ServerPort, SmtpUser.FixSqlString(75), SmtpPassword.EncryptString(), FromEmail.FixSqlString(75), FromUsername.FixSqlString(75), (RequireAuth) ? "1" : "0", (RequireSsl) ? "1" : "0", Id)); _instance = LoadSystemSettings(); }