當前位置: 首頁>>代碼示例>>C#>>正文


C# User.ToMailAddress方法代碼示例

本文整理匯總了C#中NuGetGallery.User.ToMailAddress方法的典型用法代碼示例。如果您正苦於以下問題:C# User.ToMailAddress方法的具體用法?C# User.ToMailAddress怎麽用?C# User.ToMailAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NuGetGallery.User的用法示例。


在下文中一共展示了User.ToMailAddress方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SendPackageOwnerConfirmation

        public void SendPackageOwnerConfirmation(User fromUser, User toUser, PackageRegistration package)
        {
            if (!toUser.EmailAllowed) return;
            var packageUrl = string.Format(
                "{0}packages/{1}", EnsureTrailingSlash(Configuration.ReadAppSettings("SiteRoot")), package.Id);

            string subject = "[{0}] The user '{1}' has added you as a maintainer of the package '{2}'.";

            string body = @"The user '{0}' has added you as a maintainer of the package '{1}'. 

Package Url: {2}

Thanks,
The {3} Team";

            body = String.Format(
                CultureInfo.CurrentCulture, body, fromUser.Username, package.Id, packageUrl, settings.GalleryOwnerName);

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = String.Format(
                    CultureInfo.CurrentCulture, subject, settings.GalleryOwnerName, fromUser.Username, package.Id);
                mailMessage.Body = body;
                mailMessage.From = fromUser.ToMailAddress();

                mailMessage.To.Add(toUser.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:chocolatey,項目名稱:chocolatey.org,代碼行數:29,代碼來源:MessageService.cs

示例2: SendPasswordResetInstructions

        public void SendPasswordResetInstructions(User user, string resetPasswordUrl)
        {
            string body = @"The word on the street is you lost your password. Sorry to hear it!
If you haven't forgotten your password you can safely ignore this email. Your password has not been changed.

Click the following link within the next {0} hours to reset your password:

{1}

Thanks,
The {2} Team";

            body = String.Format(
                CultureInfo.CurrentCulture,
                body,
                Constants.DefaultPasswordResetTokenExpirationHours,
                resetPasswordUrl,
                settings.GalleryOwnerName);

            string subject = String.Format(
                CultureInfo.CurrentCulture, "[{0}] Please reset your password.", settings.GalleryOwnerName);
            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.From = new MailAddress(settings.GalleryOwnerEmail, settings.GalleryOwnerName);

                mailMessage.To.Add(user.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:chocolatey,項目名稱:chocolatey.org,代碼行數:31,代碼來源:MessageService.cs

示例3: SendPackageOwnerRequest

        public void SendPackageOwnerRequest(User fromUser, User toUser, PackageRegistration package, string confirmationUrl)
        {
            if (!toUser.EmailAllowed) return;

            string subject = "[{0}] The user '{1}' wants to add you as a maintainer of the package '{2}'.";

            string body = @"The user '{0}' wants to add you as a maintainer of the package '{1}'. 
If you do not want to be listed as a maintainer of this package, simply delete this email.

To accept this request and become a listed maintainer of the package, click the following URL:

{2}

Thanks,
The {3} Team";

            body = String.Format(
                CultureInfo.CurrentCulture, body, fromUser.Username, package.Id, confirmationUrl, settings.GalleryOwnerName);

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = String.Format(
                    CultureInfo.CurrentCulture, subject, settings.GalleryOwnerName, fromUser.Username, package.Id);
                mailMessage.Body = body;
                mailMessage.From = fromUser.ToMailAddress();

                mailMessage.To.Add(toUser.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:chocolatey,項目名稱:chocolatey.org,代碼行數:30,代碼來源:MessageService.cs

示例4: SendPasswordResetInstructions

        public void SendPasswordResetInstructions(User user, string resetPasswordUrl, bool forgotPassword)
        {
            string body = String.Format(
                CultureInfo.CurrentCulture,
                forgotPassword ? Strings.Emails_ForgotPassword_Body : Strings.Emails_SetPassword_Body,
                Constants.DefaultPasswordResetTokenExpirationHours,
                resetPasswordUrl,
                Config.GalleryOwner.DisplayName);

            string subject = String.Format(CultureInfo.CurrentCulture, forgotPassword ? Strings.Emails_ForgotPassword_Subject : Strings.Emails_SetPassword_Subject, Config.GalleryOwner.DisplayName);
            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.From = Config.GalleryOwner;

                mailMessage.To.Add(user.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:atrevisan,項目名稱:NuGetGallery,代碼行數:20,代碼來源:MessageService.cs

示例5: SendSupportMessage

        private void SendSupportMessage(User user, string body, string subject)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.From = Config.GalleryOwner;

                mailMessage.To.Add(user.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:atrevisan,項目名稱:NuGetGallery,代碼行數:17,代碼來源:MessageService.cs

示例6: SendPackageOwnerRemovedNotice

        public void SendPackageOwnerRemovedNotice(User fromUser, User toUser, PackageRegistration package)
        {
            if (!toUser.EmailAllowed)
            {
                return;
            }

            const string subject = "[{0}] The user '{1}' has removed you as an owner of the package '{2}'.";

            string body = @"The user '{0}' removed you as an owner of the package '{1}'.

If this was done incorrectly, we'd recommend contacting '{0}' at '{2}'.

Thanks,
The {3} Team";
            body = String.Format(CultureInfo.CurrentCulture, body, fromUser.Username, package.Id, fromUser.EmailAddress, Config.GalleryOwner.DisplayName);

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = String.Format(CultureInfo.CurrentCulture, subject, Config.GalleryOwner.DisplayName, fromUser.Username, package.Id);
                mailMessage.Body = body;
                mailMessage.From = Config.GalleryNoReplyAddress;
                mailMessage.ReplyToList.Add(fromUser.ToMailAddress());

                mailMessage.To.Add(toUser.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:NuGet,項目名稱:NuGetGallery,代碼行數:28,代碼來源:MessageService.cs

示例7: SendSupportMessage

        private void SendSupportMessage(User user, string body, string subject)
        {
            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = subject;
                mailMessage.Body = body;
                mailMessage.From = Config.GalleryOwner;

                mailMessage.To.Add(user.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:Pliner,項目名稱:NuGetGallery,代碼行數:12,代碼來源:MessageService.cs

示例8: SendPackageOwnerRequest

        public void SendPackageOwnerRequest(User fromUser, User toUser, PackageRegistration package, string confirmationUrl, string message)
        {
            if (!toUser.EmailAllowed)
            {
                return;
            }

            const string subject = "[{0}] The user '{1}' wants to add you as an owner of the package '{2}'.";

            string body = string.Format(CultureInfo.CurrentCulture, [email protected]"The user '{fromUser.Username}' wants to add you as an owner of the package '{package.Id}'.
If you do not want to be listed as an owner of this package, simply delete this email.

To accept this request and become a listed owner of the package, click the following URL:

[{confirmationUrl}]({confirmationUrl})");


            if (!string.IsNullOrWhiteSpace(message))
            {
                body += Environment.NewLine + Environment.NewLine + string.Format(CultureInfo.CurrentCulture, [email protected]"The user '{fromUser.Username}' added the following message for you:

'{message}'");
            }

            body += Environment.NewLine + Environment.NewLine + [email protected]"Thanks,
The {Config.GalleryOwner.DisplayName} Team";

            using (var mailMessage = new MailMessage())
            {
                mailMessage.Subject = String.Format(CultureInfo.CurrentCulture, subject, Config.GalleryOwner.DisplayName, fromUser.Username, package.Id);
                mailMessage.Body = body;
                mailMessage.From = Config.GalleryNoReplyAddress;
                mailMessage.ReplyToList.Add(fromUser.ToMailAddress());

                mailMessage.To.Add(toUser.ToMailAddress());
                SendMessage(mailMessage);
            }
        }
開發者ID:NuGet,項目名稱:NuGetGallery,代碼行數:38,代碼來源:MessageService.cs

示例9: UsesTypeCaptionToDescribeCredentialIfNoProviderNounPresent

            public void UsesTypeCaptionToDescribeCredentialIfNoProviderNounPresent()
            {
                var user = new User { EmailAddress = "[email protected]", Username = "foo" };
                var cred = CredentialBuilder.CreatePbkdf2Password("bogus");
                var messageService = new TestableMessageService();
                messageService.MockAuthService
                    .Setup(a => a.DescribeCredential(cred))
                    .Returns(new CredentialViewModel() {
                        TypeCaption = "Password"
                    });

                messageService.SendCredentialAddedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Password added to your account", message.Subject);
                Assert.Contains("A Password was added to your account", message.Body);
            }
開發者ID:ZhiYuanHuang,項目名稱:NuGetGallery,代碼行數:19,代碼來源:MessageServiceFacts.cs

示例10: UsesProviderNounToDescribeCredentialIfPresent

            public void UsesProviderNounToDescribeCredentialIfPresent()
            {
                var user = new User { EmailAddress = "[email protected]", Username = "foo" };
                var cred = CredentialBuilder.CreateExternalCredential("MicrosoftAccount", "abc123", "Test User");
                var messageService = new TestableMessageService();
                messageService.MockAuthService
                    .Setup(a => a.DescribeCredential(cred))
                    .Returns(new CredentialViewModel() {
                        AuthUI = new AuthenticatorUI("sign in", "Microsoft Account", "Microsoft Account")
                    });

                messageService.SendCredentialAddedNotice(user, cred);
                var message = messageService.MockMailSender.Sent.Last();

                Assert.Equal(user.ToMailAddress(), message.To[0]);
                Assert.Equal(TestGalleryOwner, message.From);
                Assert.Equal("[Joe Shmoe] Microsoft Account added to your account", message.Subject);
                Assert.Contains("A Microsoft Account was added to your account", message.Body);
            }
開發者ID:ZhiYuanHuang,項目名稱:NuGetGallery,代碼行數:19,代碼來源:MessageServiceFacts.cs

示例11: SendPackageOwnerRequest

        public MailMessage SendPackageOwnerRequest(User fromUser, User toUser, PackageRegistration package, string confirmationUrl)
        {
            if (!toUser.EmailAllowed)
            {
                return null;
            }

            string subject = "[{0}] The user '{1}' wants to add you as an owner of the package '{2}'.";

            string body = @"The user '{0}' wants to add you as an owner of the package '{1}'. 
If you do not want to be listed as an owner of this package, simply delete this email.

To accept this request and become a listed owner of the package, click the following URL:

[{2}]({2})

Thanks,
The {3} Team";

            body = String.Format(body, fromUser.Username, package.Id, confirmationUrl, settings.GalleryOwnerName);

            using (
                var mailMessage = new MailMessage
                {
                    Subject = String.Format(subject, settings.GalleryOwnerName, fromUser.Username, package.Id),
                    Body = body,
                    From = fromUser.ToMailAddress(),
                })
            {
                mailMessage.To.Add(toUser.ToMailAddress());
                SendMessage(mailMessage);
                return mailMessage;
            }
        }
開發者ID:avieru,項目名稱:NuGetGallery,代碼行數:34,代碼來源:MessageService.cs

示例12: SendPasswordResetInstructions

        public MailMessage SendPasswordResetInstructions(User user, string resetPasswordUrl)
        {
            string body = @"The word on the street is you lost your password. Sorry to hear it!
If you haven't forgotten your password you can safely ignore this email. Your password has not been changed.

Click the following link within the next {0} hours to reset your password:

[{1}]({1})

Thanks,
The {2} Team";

            body = String.Format(body,
                Const.DefaultPasswordResetTokenExpirationHours,
                resetPasswordUrl,
                settings.GalleryOwnerName);

            using (
                var mailMessage = new MailMessage
                {
                    Subject = String.Format("[{0}] Please reset your password.", settings.GalleryOwnerName),
                    Body = body,
                    From = new MailAddress(settings.GalleryOwnerEmail, settings.GalleryOwnerName),
                })
            {
                mailMessage.To.Add(user.ToMailAddress());
                SendMessage(mailMessage);
                return mailMessage;
            }
        }
開發者ID:avieru,項目名稱:NuGetGallery,代碼行數:30,代碼來源:MessageService.cs


注:本文中的NuGetGallery.User.ToMailAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。