本文整理汇总了C#中Microsoft.AspNet.Identity.IdentityMessage类的典型用法代码示例。如果您正苦于以下问题:C# IdentityMessage类的具体用法?C# IdentityMessage怎么用?C# IdentityMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentityMessage类属于Microsoft.AspNet.Identity命名空间,在下文中一共展示了IdentityMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index(ContactMessage contactForm)
{
if (!ModelState.IsValid)
{
if (contactForm.FromEmail == null || !contactForm.IsValidEmail(contactForm.FromEmail))
{
TempData["Error"] = "Please enter a valid email address.";
}
ViewBag.EmailError = TempData["Error"];
return View(contactForm);
}
var emailer = new EmailService();
var mail = new IdentityMessage
{
Subject = contactForm.Subject,
Destination = ConfigurationManager.AppSettings["ContactMeEmail"],
Body = "You have recieved a new contact form submission from " + contactForm.contactName +
"( " + contactForm.FromEmail + " ) with the following contents<br/>" + contactForm.Message
};
emailer.SendAsync(mail);
TempData["MessageSent"] = "Your message has been delivered successfully!";
return RedirectToAction("Index");
}
示例2: SendAsync
public Task SendAsync(IdentityMessage message)
{
var twilio = new TwilioGateway();
twilio.SendSms(message.Destination, message.Body);
return Task.FromResult(0);
}
示例3: ConfigSendGridasync
// Use NuGet to install SendGrid (Basic C# client lib)
private async Task ConfigSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new MailAddress(this.fromAddress, "NinjaHive System");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
// Create a Web transport for sending email.
var transportWeb = new Web(this.credentials);
// Send the email.
try
{
await transportWeb.DeliverAsync(myMessage);
}
//http://stackoverflow.com/questions/28878924/bad-request-check-errors-for-a-list-of-errors-returned-by-the-api-at-sendgrid
catch (InvalidApiRequestException ex)
{
var errorDetails = new StringBuilder();
errorDetails.Append("ResponseStatusCode: " + ex.ResponseStatusCode + ". ");
for (int i = 0; i < ex.Errors.Count(); i++)
{
errorDetails.Append($" -- Error #{i} : {ex.Errors[i]}");
}
throw new ApplicationException(errorDetails.ToString(), ex);
}
}
示例4: configSendGridasync
// Use NuGet to install SendGrid (Basic C# client lib)
private async Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
//NEED TO UPDATE THIS TO OUR DETAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! http://bitoftech.net/2015/02/03/asp-net-identity-2-accounts-confirmation-password-user-policy-configuration/
myMessage.From = new System.Net.Mail.MailAddress("[email protected]t", "Taiseer Joudeh");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
//NEED TO UPDATE THIS TO OUR DETAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! http://bitoftech.net/2015/02/03/asp-net-identity-2-accounts-confirmation-password-user-policy-configuration/
var credentials = new NetworkCredential(ConfigurationManager.AppSettings["emailService:Account"],
ConfigurationManager.AppSettings["emailService:Password"]);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
{
//Trace.TraceError("Failed to create Web transport.");
await Task.FromResult(0);
}
}
示例5: ConfigHotmailAccount
private async Task ConfigHotmailAccount(IdentityMessage message)
{
// Credentials:
var credentialUserName = ConfigurationManager.AppSettings["emailService:Account"];
var sentFrom = credentialUserName;
var pwd = ConfigurationManager.AppSettings["emailService:Password"];
// Configure the client:
System.Net.Mail.SmtpClient client =
new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
// Create the credentials:
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(credentialUserName, pwd);
client.EnableSsl = true;
client.Credentials = credentials;
// Create the message:
var mail =
new System.Net.Mail.MailMessage(sentFrom, message.Destination);
mail.Subject = message.Subject;
mail.Body = message.Body;
// Send:
await client.SendMailAsync(mail);
}
示例6: SendAsync
public async Task SendAsync(IdentityMessage message)
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add(message.Destination);
mail.From = new MailAddress("[email protected]","SEATS");
mail.Subject = message.Subject;
mail.Body = message.Body;
mail.IsBodyHtml = true;
using (SmtpClient smtp = new SmtpClient())
{
smtp.Host = "198.60.12.9";
smtp.Port = 25;
//smtp.UseDefaultCredentials = true;
await smtp.SendMailAsync(mail);
}
mail.Dispose();
}
catch (Exception ex)
{
throw new HttpException(500, "Confirmation Email Not Sent! " + ex.Message);
}
}
示例7: SendAsync
public Task SendAsync(IdentityMessage message)
{
if (ConfigurationManager.AppSettings["EmailServer"] != "{EmailServer}" &&
ConfigurationManager.AppSettings["EmailUser"] != "{EmailUser}" &&
ConfigurationManager.AppSettings["EmailPassword"] != "{EmailPassword}")
{
var mailMsg = new MailMessage();
mailMsg.To.Add(new MailAddress(message.Destination, ""));
mailMsg.From = new MailAddress("[email protected]",
"EnergieNetz Administrator");
// Subject and multipart/alternative Body
mailMsg.Subject = message.Subject;
mailMsg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(message.Body, null, MediaTypeNames.Text.Plain));
// Init SmtpClient and send
var smtpClient = new SmtpClient
{
Host = ConfigurationManager.AppSettings["EmailServer"],
Port = int.Parse(ConfigurationManager.AppSettings["Port"]), //587,
EnableSsl = true,
Credentials = new NetworkCredential(ConfigurationManager.AppSettings["EmailUser"],
ConfigurationManager.AppSettings["EmailPassword"])
};
return Task.Factory.StartNew(() => smtpClient.SendAsync(mailMsg,
"token"));
}
return Task.FromResult(0);
}
示例8: configSendGridasync
private Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress(
"[email protected]", "Joe S.");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
var credentials = new NetworkCredential(
ConfigurationManager.AppSettings["mailAccount"],
ConfigurationManager.AppSettings["mailPassword"]
);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
if (transportWeb != null)
{
return transportWeb.DeliverAsync(myMessage);
}
else
{
return Task.FromResult(0);
}
}
示例9: InviteToJoin
public async Task<ActionResult> InviteToJoin(Invitation invitationModel)
{
using (ApplicationDbContext db = new ApplicationDbContext())
{
//check to make sure that the user has access
ApplicationUser user = db.Users.FirstOrDefault(x => x.UserName == User.Identity.Name);
Household household = db.Households.FirstOrDefault(x => x.Id == invitationModel.HouseholdId);
if (!household.Members.Contains(user))
{
return RedirectToAction("Unauthorized", "Error");
}
//ApplicationDbContext db = new ApplicationDbContext();
Guid invitationCode = Guid.NewGuid();
//Save invitation model to database to check later
invitationModel.JoinCode = invitationCode;
invitationModel.UserId = User.Identity.GetUserId();
db.Invitations.Add(invitationModel);
await db.SaveChangesAsync();
IdentityMessage myMessage = new IdentityMessage();
myMessage.Destination = invitationModel.ToEmail;
myMessage.Subject = "Invitation to Join " + household.HouseholdName + " on CashCache";
var callbackUrl = Url.Action("RegisterAndAdd", "Account", new { invitationId = invitationModel.Id, guid = invitationCode }, protocol: Request.Url.Scheme);
myMessage.Body = "User " + user.UserName + " has invited you to join their household " + household.HouseholdName +
" on CashCache budget tracking application. Please click <a href =\"" + callbackUrl + "\">here</a> to accept their invitation.";
EmailService emailService = new EmailService();
await emailService.SendAsync(myMessage);
return RedirectToAction("Details", "Household", new { id = invitationModel.HouseholdId });
}
}
示例10: SendAsync
public Task SendAsync(IdentityMessage message)
{
// Twilio Begin
var Twilio = new TwilioRestClient(
System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"],
System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"]);
var result = Twilio.SendMessage(
System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"],
message.Destination, message.Body
);
//Status is one of Queued, Sending, Sent, Failed or null if the number is not valid
Trace.TraceInformation(result.Status);
//Twilio doesn't currently have an async API, so return success.
return Task.FromResult(0);
// Twilio End
// ASPSMS Begin
// var soapSms = new MvcPWx.ASPSMSX2.ASPSMSX2SoapClient("ASPSMSX2Soap");
// soapSms.SendSimpleTextSMS(
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"],
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"],
// message.Destination,
// System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"],
// message.Body);
// soapSms.Close();
// return Task.FromResult(0);
// ASPSMS End
}
示例11: configSendGridasync
// Use NuGet to install SendGrid (Basic C# client lib)
private async Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress("[email protected]", "Francisco Paz");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
// Create network credentials to access your SendGrid account
var username = "";
var pswd = "";
var credentials = new NetworkCredential(username, pswd);
//var credentials = new NetworkCredential(ConfigurationManager.AppSettings["emailService:Account"],
// ConfigurationManager.AppSettings["emailService:Password"]);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
{
//Trace.TraceError("Failed to create Web transport.");
await Task.FromResult(0);
}
}
示例12: Contact
public ActionResult Contact(ContactMessage form)
{
if (!ModelState.IsValid)
{
return View(form);
}
var emailer = new EmailService();
var mail = new IdentityMessage()
{
Destination = ConfigurationManager.AppSettings["PersonalEmail"],
Subject = form.Subject,
Body = "You have received a new contact form submission from" + form.Name + "(" + form.FromEmail + ") with the following contents:<br /><br /><br />" + form.Message
};
emailer.SendAsync(mail);
//TempData["MessageSent"] = "Your message has been delivered successfully.";
ViewBag.Messagesent = "Your message has been delivered successfully.";
return View();
//return RedirectToAction("Contact");
/* ViewBag.Message = "Contact Shane Overby";
return View();*/
}
示例13: SendAsync
public Task SendAsync(IdentityMessage message)
{
// настройка логина, пароля отправителя
const string @from = "[email protected]";
const string pass = "piwsdn2w";
// адрес и порт smtp-сервера, с которого мы и будем отправлять письмо
var client = new SmtpClient("smtp.gmail.com", 587)
{
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential(@from, pass),
EnableSsl = true
};
// создаем письмо: message.Destination - адрес получателя
var mail = new MailMessage(from, message.Destination)
{
Subject = message.Subject,
Body = message.Body,
IsBodyHtml = true
};
return client.SendMailAsync(mail);
}
示例14: ConfigSendGridasync
private async Task ConfigSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress("[email protected]", "Система за гласуване.");
myMessage.Subject = message.Subject;
myMessage.Html = message.Body;
var transportWeb = new Web("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");
try
{
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
{
await Task.FromResult(0);
}
}
catch (Exception ex)
{
throw ex;
}
}
示例15: SendAsync
public System.Threading.Tasks.Task SendAsync(IdentityMessage message)
{
MailWasSent = true;
Message = message;
return Task.FromResult<object>(null);
}