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


C# Postal.Email类代码示例

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


Email类属于Postal命名空间,在下文中一共展示了Email类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Alternative_views_are_added_to_MailMessage

        public void Alternative_views_are_added_to_MailMessage()
        {
            var input = @"
            To: [email protected]
            From: [email protected]
            Subject: Test Subject
            Views: Text, Html";
            var text = @"Content-Type: text/plain

            Hello, World!";
            var html = @"Content-Type: text/html

            <p>Hello, World!</p>";

            var email = new Email("Test");
            var renderer = new Mock<IEmailViewRenderer>();
            renderer.Setup(r => r.Render(email, "Test.Text")).Returns(text);
            renderer.Setup(r => r.Render(email, "Test.Html")).Returns(html);

            var parser = new EmailParser(renderer.Object);
            using (var message = parser.Parse(input, email))
            {
                message.AlternateViews[0].ContentType.ShouldEqual(new ContentType("text/plain; charset=utf-16"));
                var textContent = new StreamReader(message.AlternateViews[0].ContentStream).ReadToEnd();
                textContent.ShouldEqual("Hello, World!");

                message.AlternateViews[1].ContentType.ShouldEqual(new ContentType("text/html; charset=utf-16"));
                var htmlContent = new StreamReader(message.AlternateViews[1].ContentStream).ReadToEnd();
                htmlContent.ShouldEqual("<p>Hello, World!</p>");
            }
        }
开发者ID:robitar,项目名称:postal,代码行数:31,代码来源:EmailParserTests.cs

示例2: NotifyPlayerForAttention

		public async Task NotifyPlayerForAttention(string userId, string subject, string message, string gameId)
		{
			var userClaims = await _userManager.GetClaimsAsync(userId);

			var emailClaim = userClaims.FirstOrDefault(claim => claim.Type == ClaimTypes.Email);

			if (emailClaim == null)
				return;

			dynamic email = new Email("HailUser");
			email.To = emailClaim.Value;
			email.Subject = subject;
			email.Message = message;
            email.GameId = gameId;

			var service = new Postal.EmailService(System.Web.Mvc.ViewEngines.Engines, () =>
			{
				if (string.IsNullOrWhiteSpace(SMTPServer) || string.IsNullOrWhiteSpace(SMTPUsername) || string.IsNullOrWhiteSpace(SMTPPassword) || string.IsNullOrWhiteSpace(SMTPPort))
				{
					return new SmtpClient();
				}

				return new SmtpClient(SMTPServer, int.Parse(SMTPPort))
				{
					EnableSsl = true,
					Credentials = new NetworkCredential(SMTPUsername, SMTPPassword)
				};
			});

			await service.SendAsync(email);
		}
开发者ID:verneroberts,项目名称:ResistanceOnline,代码行数:31,代码来源:EmailService.cs

示例3: SendAsync

        public Task SendAsync(IdentityMessage message)
        {
            Postal.EmailService emailService = new Postal.EmailService(ViewEngines.Engines);

            var fromEmail = SecureSettings.GetValue("smtp:From");
            var host = SecureSettings.GetValue("smtp:Host");
            if (!string.IsNullOrEmpty(host))
            {
                emailService = new Postal.EmailService(ViewEngines.Engines, () => CreateMySmtpClient());
            }

            dynamic email = new Email("IdentityMessageService");
            email.To = message.Destination;
            if (!string.IsNullOrEmpty(fromEmail))
            {
                email.From = fromEmail;
            }
            else
            {
                fromEmail = ConfigurationManager.AppSettings["NoReplyEmail"];
                if (string.IsNullOrEmpty(fromEmail)) fromEmail = "[email protected]";
                email.From = fromEmail;
            }

            email.Subject = message.Subject;
            email.Body = message.Body;

            return emailService.SendAsync(email);

               // return email.SendAsync();

            //return Task.FromResult(0);
        }
开发者ID:kdcllc,项目名称:KDCLLCWeb,代码行数:33,代码来源:EmailService.cs

示例4: Register

        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    string confirmationToken =
                        WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true);
                    dynamic email = new Email("RegEmail");
                    email.To = model.Email;
                    email.UserName = model.UserName;
                    email.ConfirmationToken = confirmationToken;
                    email.Send();

                    return RedirectToAction("RegisterStepTwo", "Account");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
开发者ID:RolfVeinoeSorensen,项目名称:EasyModules.NET,代码行数:26,代码来源:AccountController.cs

示例5: Contact

        public async Task<ActionResult> Contact(Models.ContactViewModel contact)
        {
            if (ModelState.IsValid)
            {
                var currentTime = DateTime.UtcNow;
                var elapsedTime = currentTime - contact.TimeSent;
                bool spamFieldFull = !string.IsNullOrEmpty(contact.Check);

                dynamic email = new Email("ContactForm");
                email.From = contact.Email;
                email.CurrentTime = currentTime;
                email.Name = contact.Name;
                email.Title = contact.Title;
                email.Phone = contact.Phone;
                email.Company = contact.Company;
                email.Address = contact.Address;
                email.City = contact.City;
                email.State = contact.State;
                email.Zip = contact.Zip;
                email.Country = contact.Country;
                email.Comments = contact.Comments;
                email.Elapsed = elapsedTime;
                email.SpamFieldFull = spamFieldFull;

                await email.SendAsync();
                return RedirectToAction("ContactSuccess");                                
            }

            return View(contact);
        }
开发者ID:sjpence,项目名称:unitdesign-web,代码行数:30,代码来源:HomeController.cs

示例6: Contact

        public ActionResult Contact(ContactModel model)
        {
            // Build the contact email using a dynamic object for flexibility
            dynamic email = new Email("Contact");
            email.To = ConfigurationManager.AppSettings["email:ContactToAddress"];
            email.From = ConfigurationManager.AppSettings["email:ContactFromAddress"];
            email.FirstName = model.FirstName;
            email.LastName = model.LastName;
            email.BusinessType = model.BusinessType;
            email.AddressLine1 = model.AddressLine1;
            email.AddressLine2 = model.AddressLine2;
            email.City = model.City;
            email.State = model.State;
            email.ZipCode = model.ZipCode;
            email.Country = model.Country == "Other" ? model.CountryName : model.Country;
            email.Phone = model.Phone;
            email.Email = model.Email;
            email.Comments = model.Comments;
            email.Send();

            // Set the ShowThanksMessage flag to provide user feedback on the page.
            model.ShowThanksMessage = true;

            return View(model);
        }
开发者ID:jrhines,项目名称:lafayette-testing-services,代码行数:25,代码来源:HomeController.cs

示例7: Send

        public void Send(string content)
        {
            _smtpClient = new SmtpClient(Address, Port);
            _smtpClient.Credentials = new NetworkCredential(Account, Password);
            _smtpClient.EnableSsl = false;
            MailMessage mailMessage = new MailMessage();
            mailMessage.BodyEncoding = Encoding.UTF8;
            mailMessage.From = new MailAddress(From, SenderName, Encoding.UTF8);
            mailMessage.To.Add(To);
            mailMessage.Body = content;
            mailMessage.Subject = Subject;
            _smtpClient.Send(mailMessage);


            dynamic email = new Email("Example");
            email.To = "[email protected]";
            email.Send();


            var viewsPath = Path.GetFullPath(@"..\..\Views");

            var engines = new ViewEngineCollection();
            engines.Add(new FileSystemRazorViewEngine(viewsPath));

            var service = new EmailService(engines);
            dynamic email = new Email("Test");

            // Will look for Test.cshtml or Test.vbhtml in Views directory.
            email.Message = "Hello, non-asp.net world!";
            service.Send(email);
           // RESTORE DATABASE is terminating abnormally.
        }
开发者ID:ilkerhalil,项目名称:ZiylanEtl,代码行数:32,代码来源:Mailer.cs

示例8: MultiPart

 public ActionResult MultiPart()
 {
     dynamic email = new Email("MultiPart");
     email.Date = DateTime.UtcNow.ToString();
     
     return new EmailViewResult(email);
 }
开发者ID:auswm85,项目名称:postal,代码行数:7,代码来源:PreviewController.cs

示例9: Simple

 public ActionResult Simple()
 {
     dynamic email = new Email("Simple");
     email.Date = DateTime.UtcNow.ToString();
     
     return new EmailViewResult(email);
 }
开发者ID:auswm85,项目名称:postal,代码行数:7,代码来源:PreviewController.cs

示例10: Index

        //
        // GET: /Manage/Index
        public async Task<ActionResult> Index(ManageMessageId? message, string requirements)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId = User.Identity.GetUserId();
            var model = new IndexViewModel
            {
                HasPassword = HasPassword(),
                PhoneNumber = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };
            if (requirements != null)
            {
                string session_user = User.Identity.GetUserId();
                AspNetUsers anu;
                TempData["succMess"] = "Your message was sent to administrator!";

                dynamic email = new Email("View");
                email.to = "[email protected]";
                email.message = requirements;
                anu = db.AspNetUsers.Single(a => a.Id == session_user);
                email.ID = anu.Email;
                email.Send();
            }
            return View(model);
        }
开发者ID:ZuzkaP,项目名称:BPPS_new,代码行数:37,代码来源:ManageController.cs

示例11: SendHKNews

        public static bool SendHKNews(HKNewsPaper paper)
        {
            dynamic email = new Email("~/MailTemplates/HKNews.cshtml");
            email.Model = paper;
            email.Send();

            return true;
        }
开发者ID:hurtonypeter,项目名称:onlab,代码行数:8,代码来源:MailHelper.cs

示例12: WelcomeSendPassword

 public static void WelcomeSendPassword(string username, string toaddress, string pass)
 {
     dynamic email = new Email("~/MailTemplates/Teszt.cshtml");
     email.To = toaddress;
     email.UserName = username;
     email.Password = pass;
     email.Send();
 }
开发者ID:hurtonypeter,项目名称:onlab,代码行数:8,代码来源:MailHelper.cs

示例13: Getting_dynamic_property_reads_from_ViewData

        public void Getting_dynamic_property_reads_from_ViewData()
        {
            var email = new Email("Test");
            email.ViewData["Subject"] = "SubjectValue";

            dynamic email2 = email;
            Assert.Equal("SubjectValue", email2.Subject);
        }
开发者ID:Choulla-Naresh8264,项目名称:postal,代码行数:8,代码来源:EmailTests.cs

示例14: Dynamic_property_setting_assigns_ViewData_value

        public void Dynamic_property_setting_assigns_ViewData_value()
        {
            dynamic email = new Email("Test");
            email.Subject = "SubjectValue";

            var email2 = (Email)email;
            email2.ViewData["Subject"].ShouldEqual("SubjectValue");
        }
开发者ID:Choulla-Naresh8264,项目名称:postal,代码行数:8,代码来源:EmailTests.cs

示例15: Render

 public string Render(Email email, string viewName = null)
 {
     viewName = viewName ?? email.ViewName;
     var controllerContext = CreateControllerContext();
     var view = CreateView(viewName, controllerContext);
     var viewOutput = RenderView(view, email.ViewData, controllerContext);
     return viewOutput;
 }
开发者ID:mcaradec,项目名称:postal,代码行数:8,代码来源:EmailViewRenderer.cs


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