public static void Main(string[] args) { var emailCreator = new EmailCreator(new ExactTargetConfiguration { ApiUserName = "", ApiPassword = "", EndPoint = "https://webservice.s6.exacttarget.com/Service.asmx" }); const int templateId = 1802; try { var id = emailCreator.Create(templateId, "test-email", "test-subject", new KeyValuePair <string, string>("DynamicArea", "<p>Test content</p>") ); Console.Write("Done {0}", id); } catch (Exception ex) { Console.Write(ex); } Console.ReadKey(); }
public EmailCreatorTests() { _emailContextProviderMock = new Mock <IEmailContextProvider>(); _emailFactoryProducerMock = new Mock <IEmailFactoryProducer>(); _emailFactoryProducerMock.Setup(producer => producer.GetEmailFactory(It.IsAny <string>())) .Returns(( string templateType) => { if (templateType.ToUpperInvariant() == "BYUSER") { return(_byUserEmailFactoryMock.Object); } return(_commonEmailFactoryMock.Object); }); _byUserEmailFactoryMock = new Mock <ByUserEmailFactory>(); _byUserEmailFactoryMock.Setup(byuserFactory => byuserFactory.CreateEmails(It.IsAny <EmailTemplateContent>(), It.IsAny <EmailContext>())) .Returns(new List <Email>()); _commonEmailFactoryMock = new Mock <CommonEmailFactory>(); _commonEmailFactoryMock.Setup(commonFactory => commonFactory.CreateEmails(It.IsAny <EmailTemplateContent>(), It.IsAny <EmailContext>())) .Returns(new List <Email>()); _emailCreator = new EmailCreator(_emailContextProviderMock.Object, _emailFactoryProducerMock.Object); }
public MessageController(IHttpContextAccessor accessor) : base(accessor) { ToBuyContext context = new ToBuyContext(); messageService = new MessageService(context); crea = new EmailCreator(context); userService = new UserService(context); }
public void ForgotPassword(string email) { var secret = service.ForgotPassword(email); if (secret != null) { EmailCreator creator = new EmailCreator(context); var mail = creator.GeneratePasswordMail(secret.Name, secret.Secret, email); EmailSender sender = new EmailSender(); sender.SendMessage(mail); } }
//[AllowAnonymous] public virtual async Task <string> ForgotPassword(ForgotPasswordModel model, CancellationToken cancellationToken, bool isFirstTime = false) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { throw new BadRequestException("حساب کاربری با ایمیل وارد شده یافت نشد!"); } var code = await _userService.GeneratePasswordResetToken(model, cancellationToken); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); //var callbackUrl = Url.RouteUrl( // "ResetPassword", // new { code, email = user.Email }, // Request.Scheme); var callbackUrl = Url.Action("ResetPassword", "Account", new { code, email = user.Email }, HttpContext.Request.Scheme); if (!isFirstTime) { await _emailSender.SendEmailAsync(new MailRequest { ToEmail = user.Email, Subject = "بازیابی رمزعبور", Body = await EmailCreator.Create(new EmailCreatorModel { BodyText = "برای تغییر رمز عبور خود بر روی لینک زیر کلیک کنید", Link = HtmlEncoder.Default.Encode(callbackUrl), Name = user.FullName }, _webHostEnvironment.WebRootPath, cancellationToken) }); } else { await _emailSender.SendEmailAsync(new MailRequest { ToEmail = user.Email, Subject = "هدف سنج", Body = await EmailCreator.Create(new EmailCreatorModel { BodyText = "شما به یک محیط کاری در هدف سنج اضافه شده اید . برای ادامه روی لینک زیر کلیک کنید.", Link = HtmlEncoder.Default.Encode(callbackUrl), Name = "سلام کاربر عزیز" }, _webHostEnvironment.WebRootPath, cancellationToken) }); } return("لطفا ایمیل خود را چک کنید،جهت تغییر کلمه عبور،ایمیلی برای شما ارسال شده است"); }
public void DoSomethingComplexWithWrapper() { // Pretend there is business-logic here // Send an e-mail - version behind wrapper/facade, with multiple "to", "cc", and "bcc" addresses. EmailCreator.CreateEmailFrom("*****@*****.**") .To("*****@*****.**", "*****@*****.**", "*****@*****.**") .CC("*****@*****.**", "*****@*****.**") .BCC("*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**") .WithSubject("Email subject here") .WithBody("Email body here") .Send(); }
public async Task <ApiResult <string> > SendEmail(ResendEmailModel model, CancellationToken cancellationToken) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { throw new BadRequestException("حساب کاربری با ایمیل وارد شده یافت نشد!"); } var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = code }, HttpContext.Request.Scheme); var encodedLink = HtmlEncoder.Default.Encode(callbackUrl); await _emailSender.SendEmailAsync(new MailRequest { ToEmail = model.Email, Subject = "تایید ایمیل هدف سنج", Body = await EmailCreator.Create(new EmailCreatorModel { BodyText = "برای تایید ایمیل خودتون بر روی دکمه زیر کلیک کنید", Link = encodedLink, Name = $"{user.Email.Split('@')[0]} عزیز ، سلام" }, _webHostEnvironment.WebRootPath, cancellationToken) }); return(encodedLink); }
private void goButton_Click(object sender, EventArgs e) { string oppContactsFolderLocation = @"C:\Users\FTCC\Desktop\Opportunities"; string machformEntryFile = @"C:\Users\FTCC\Desktop\OppTester\BDSOpportunityAssignment.xlsx"; string htmlTemplateFile = @"C:\Users\FTCC\Desktop\OppTester\OppEmailHTML.html"; OppEntry_Html_Creator.EntryManager entryManager = new EntryManager(); OppEntry_Html_Creator.HTMLCreator htmlCreator = new HTMLCreator(); Opp_Email_Manager.EmailCreator emailCreator = new EmailCreator(); List <string[]> oppList = entryManager.GetEntriesFromFile(machformEntryFile); foreach (string[] oppEntryFormData in oppList) { string solicationNumber = oppEntryFormData[0]; string oppTitle = oppEntryFormData[3]; string bdsEmailAddress = oppEntryFormData[2]; string html = htmlCreator.UpdateEmailHTML(oppEntryFormData, htmlTemplateFile); emailCreator.CreateEmailWithContacts( emailCreator.GetContactsFromFile(solicationNumber, oppContactsFolderLocation) , oppTitle, html, bdsEmailAddress); } }
static void Main() { string separator = "**********************************************************************"; string title = String.Empty; #region Lazy objects testing title = "Lazy objects testing"; Console.WriteLine(separator); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "\t{0}", title)); Console.WriteLine(separator); Console.WriteLine(); LazyCustomer customer = new LazyCustomer(1); Console.WriteLine("LazyCustomer customer = new LazyCustomer(1);"); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Are orders created ? {0}", customer.Orders.IsValueCreated ? "Yes" : "No")); Console.ReadLine(); List <Order> orders = customer.Orders.Value; Console.WriteLine("List<Order> orders = customer.Orders.Value;"); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Are orders created ? {0}", customer.Orders.IsValueCreated ? "Yes" : "No")); Console.ReadLine(); #endregion #region Factory testing Console.Clear(); title = "Factory testing"; Console.WriteLine(separator); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "\t{0}", title)); Console.WriteLine(separator); Console.WriteLine(); Console.WriteLine("IMonster monster = MonsterFactory.CreateRandom();"); for (int i = 0; i < 10; i++) { IMonster monster = MonsterFactory.CreateRandom(); Console.WriteLine(monster.Attack()); } Console.ReadLine(); #endregion #region Reflection Console.Clear(); title = "Reflection"; Console.WriteLine(separator); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "\t{0}", title)); Console.WriteLine(separator); Console.WriteLine(); Assembly assembly = Assembly.LoadFrom(@"C:\Projects\Git\Playground\Playground\bin\Debug\Playground.exe"); List <Type> listClass = assembly.GetTypes().Where(x => typeof(IMonster).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract).ToList(); Console.WriteLine("Liste des classes qui implémentent l'interface IMonster : "); Console.WriteLine(); List <IMonster> listMonsters = new List <IMonster>(); foreach (Type item in listClass) { var inst = (IMonster)Activator.CreateInstance(item); listMonsters.Add(inst); } Console.WriteLine("Instanciation dynamique des classes : "); foreach (IMonster monster in listMonsters) { Console.WriteLine(monster.ToString()); } Console.ReadLine(); #endregion #region WrapperPattern Console.Clear(); title = "Wrapper Pattern"; Console.WriteLine(separator); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "\t{0}", title)); Console.WriteLine(separator); Console.WriteLine(); EmailCreator.CreateEmailFrom("*****@*****.**") .To("*****@*****.**", "*****@*****.**") .CC("*****@*****.**") .BCC("*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**") .WithSubject("Email subject here") .WithBody("Email body here").Send(); #endregion #region Decorator Pattern Console.Clear(); title = "Decorator Pattern"; Console.WriteLine(separator); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "\t{0}", title)); Console.WriteLine(separator); Console.WriteLine(); AbstractCoffee coffee = null; // We cannot create instance of abstract class coffee = new Topping(coffee); coffee = new Sugar(coffee); coffee = new Milk(coffee); Console.WriteLine("Coffee with " + coffee.ShowCoffee()); Console.ReadLine(); #endregion }