• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Identity.IdentityMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.Identity.IdentityMessage的典型用法代码示例。如果您正苦于以下问题:C# IdentityMessage类的具体用法?C# IdentityMessage怎么用?C# IdentityMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IdentityMessage类属于Microsoft.AspNet.Identity命名空间,在下文中一共展示了IdentityMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: SendGridAsync

        private async Task SendGridAsync(IdentityMessage message)
        {
            var sec = (ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection);

            if (sec != null)
            {
                var displayName = sec.From;
                var fromEmailAddress = sec.Network.UserName;
                var passwordEmail = sec.Network.Password;

                var sendMessage = new SendGridMessage()
                {
                    From = new MailAddress(fromEmailAddress, displayName),
                    Subject = message.Subject,
                    Text = message.Body,
                    Html = message.Body
                };
                sendMessage.AddTo(message.Destination);

                var credentials = new NetworkCredential(fromEmailAddress, passwordEmail);
                var transportWeb = new Web(credentials);
                if (transportWeb != null)
                {
                    await transportWeb.DeliverAsync(sendMessage);
                }
                else
                {
                    await Task.FromResult(0);
                }
            }
            else
            {
                await Task.FromResult(0);
            }
        }
开发者ID:ranieresilva,项目名称:ingresso,代码行数:35,代码来源:EmailService.cs


示例17: ConfigAndSendMessage

        private async Task ConfigAndSendMessage(IdentityMessage message)
        {
            _smtpServer = "msex1.office.finam.ru";
            _from = "[email protected]";
            try
            {
                var email = new MailMessage(new MailAddress(_from), new MailAddress(message.Destination))
                {
                    Subject = message.Subject,
                    Body = message.Body,
                    IsBodyHtml = true
                };

                using (var client = new SmtpClient())
                {
                    client.Host = _smtpServer;
                    client.Port = 25;
                    client.Credentials = new NetworkCredential("[email protected]", "UfrRJzmuR89k");
                    // client.UseDefaultCredentials = true;
                    await client.SendMailAsync(email);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Send message error", ex.ToString());
            }
        }
开发者ID:Eugene-Ishkov,项目名称:RestService,代码行数:27,代码来源:MailService.cs


示例18: SendAsync

        //методы
        public Task SendAsync(IdentityMessage message)
        {
            try
            {
                Configuration configurationFile = WebConfigurationManager.OpenWebConfiguration("~/web.config");
                MailSettingsSectionGroup mailSettings = configurationFile
                    .GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;

                string from = mailSettings.Smtp.Network.UserName;
                MailMessage msg = new MailMessage(from, message.Destination, message.Subject, message.Body);
                msg.IsBodyHtml = true;
                msg.BodyEncoding = Encoding.UTF8;
                msg.SubjectEncoding = Encoding.UTF8;

                using (SmtpClient client = new SmtpClient())
                {
                    client.Timeout = 10 * 1000;
                    client.Send(msg);
                }
            }
            catch (Exception ex)
            {
                _logger.Exception(ex);
            }

            return Task.FromResult(0);
        }
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:28,代码来源:SmtpEmailService.cs


示例19: SendAsync

 public Task SendAsync(IdentityMessage message)
 {
     return Task.Factory.StartNew(() =>
     {
         this.Send(message);
     });
 }
开发者ID:rsuzumura,项目名称:PortalConhecimento,代码行数:7,代码来源:EmailService.cs


示例20: SendEmailAsync

        private void SendEmailAsync(IdentityMessage message)
        {
            #region formatter

            string text = string.Format("Please click on this link to {0}: <a href=\"{1}\">", message.Subject, message.Body);
            string html = "Please " + message.Subject + " by clicking this link: <a href=\"" + message.Body + "\">link</a><br/><br>";
            html += HttpUtility.HtmlEncode(@"Or copy the following link on the browser: " + message.Body);

            #endregion

            var emailAddress = ConfigurationManager.AppSettings["mailAccount"];
            var password = ConfigurationManager.AppSettings["mailPassword"];
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(emailAddress);
            msg.To.Add(new MailAddress(message.Destination));
            msg.Subject = message.Subject;
            msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(text, null, MediaTypeNames.Text.Plain));
            msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));

            SmtpClient smtp = new SmtpClient();
            smtp.Host = "mail.xivtech.com";
            smtp.Port = 25;
            smtp.Credentials = new NetworkCredential(emailAddress, password);
            smtp.Timeout = 20000;
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(emailAddress, password);
            smtp.Credentials = credentials;
            //smtp.EnableSsl = true;
            smtp.Send(msg);
        }
开发者ID:dradkins,项目名称:contact-manager,代码行数:29,代码来源:EmailService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Identity.IdentityResult类代码示例发布时间:2022-05-26
下一篇:
C# Internal.DefaultHttpContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap