当前位置: 首页>>代码示例>>C#>>正文


C# Identity.IdentityMessage类代码示例

本文整理汇总了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");
        }
开发者ID:rgoodwin16,项目名称:My-Website,代码行数:29,代码来源:ContactController.cs

示例2: SendAsync

        public Task SendAsync(IdentityMessage message)
        {
            var twilio = new TwilioGateway();
            twilio.SendSms(message.Destination, message.Body);

            return Task.FromResult(0);
        }
开发者ID:devfunkd,项目名称:aquaponic-raspberry-pi,代码行数:7,代码来源:SmsService.cs

示例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);
            }
        }
开发者ID:NinjaVault,项目名称:NinjaHive,代码行数:32,代码来源:SendGridEmailService.cs

示例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);
            }
        }
开发者ID:ThePantry,项目名称:Pantry-Server,代码行数:30,代码来源:EmailService.cs

示例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);
        }
开发者ID:evangistudio,项目名称:OA2B.AuthCabinet,代码行数:32,代码来源:EmailService.cs

示例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);
            }
        }
开发者ID:sshiotani,项目名称:SEATS,代码行数:28,代码来源:EmailService.cs

示例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);
        }
开发者ID:htw-bui,项目名称:EnergieNetz,代码行数:34,代码来源:EmailService.cs

示例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);
            }
        }
开发者ID:YangTianb,项目名称:asp.net,代码行数:28,代码来源:EmailService.cs

示例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 });
            }
        }
开发者ID:evtolley,项目名称:CashCache,代码行数:34,代码来源:InvitationController.cs

示例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
        }
开发者ID:rohitiscancerian,项目名称:VGWagers,代码行数:28,代码来源:SMSService.cs

示例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);
            }
        }
开发者ID:FranPaz,项目名称:VLaboralApi,代码行数:34,代码来源:EmailService.cs

示例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();*/
        }
开发者ID:dsoverby1986,项目名称:BugTracker,代码行数:27,代码来源:HomeController.cs

示例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);
        }
开发者ID:kateEvstratenko,项目名称:groupMvcProject,代码行数:25,代码来源:EmailService.cs

示例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;
            }
        }
开发者ID:chunk1ty,项目名称:VoteSystem,代码行数:26,代码来源:EmailService.cs

示例15: SendAsync

        public System.Threading.Tasks.Task SendAsync(IdentityMessage message)
        {
            MailWasSent = true;
            Message = message;

            return Task.FromResult<object>(null);
        }
开发者ID:SBGLevelUpToolkit,项目名称:continuum-api,代码行数:7,代码来源:MockMailProvider.cs


注:本文中的Microsoft.AspNet.Identity.IdentityMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。