public async Task <JsonResult> Mensagem(int idPeca, string mensagem) { var menssagem = new Mensageria(); var messageriaService = new SendGridService(); var result = new JsonResult(); var pecaService = new PecaService(); bool sucesso = false; var nomePeca = pecaService.NomePeca(idPeca); menssagem.Assunto = "Disponibilidade da Peça: " + nomePeca; menssagem.Mensagem = mensagem; menssagem.IdPeca = idPeca; //email temporario var destinatario = "*****@*****.**"; sucesso = await messageriaService.DispararEmail(menssagem, destinatario); result.Data = new GenericTypes.AjaxResponse <int> { Ok = sucesso, MessageTitle = sucesso ? "Sucesso" : "Atenção", Message = sucesso ? "Mensagem enviada com sucesso" : "Ocorreu um erro durante o processo de envio de email, tente novamente mais tarde" }; return(result); }
public async Task <CommandResult <CommandEmptyResult> > Handle(CashOnDeliveryOrderCommand request, CancellationToken cancellationToken) { var order = _orderRepository.QueryAllIncluding(o => o.Items, o => o.DeliveryAddress, o => o.PickUpAddress, o => o.File).FirstOrDefault(a => a.Id == request.OrderId); if (order == null) { return(await Task.FromResult(CommandResult <CommandEmptyResult> .Fail("Fail to add cash on delivery paiment method order - order does not exist."))); } order.PaymentMethod = "Plaćanje pouzećem"; _unitOfWork.SaveChanges(); var sendGrid = new SendGridService(order, _configuration); var success = await sendGrid.SendMailAsync(); if (order.File != null) { order.File.Name = null; order.File.FileInBytes = null; } _unitOfWork.SaveChanges(); if (!success) { return(await Task.FromResult(CommandResult <CommandEmptyResult> .Fail(new CommandEmptyResult()))); } return(await Task.FromResult(CommandResult <CommandEmptyResult> .Success(new CommandEmptyResult()))); }
public async Task <bool> TryPublishCampaign(int campaignId, Distributor distributor) { Campaign campaign = distributor.Campaigns.Where(c => c.Id == campaignId).FirstOrDefault(); if (campaign == null) { throw new Exception("The user does not have a campaign with given ID."); } if (!IsCampaignValid(campaign)) { throw new Exception(String.Format("The campaign '{0}' is not ready to be published. Fill in missing fields.", campaign.CampaignTitle)); } try { string response = await SendGridService.SendCampaignEmail((int)campaignId, _databaseContext); if (response == "done") { return(true); } else { return(false); } } catch (Exception exception) { throw new Exception(exception.Message); } }
private async void Button_Click(object sender, RoutedEventArgs e) { try { IMailService service = new SendGridService(); var model = new MailModel { From = tbFrom.Text, ToStr = tbTo.Text, Title = tbTitle.Text, Body = new TextRange(rtbBody.Document.ContentStart, rtbBody.Document.ContentEnd).Text, }; if (file != null) { model.Attachments.Add(new MailModel.Attachment { Name = lFile.Content.ToString(), Content = file }); } MessageBox.Show(await service.Send(model)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult Log4Net(EmailMessage email) { string key = ConfigurationManager.AppSettings["Sendgrid.Key"]; SendGridService messageSvc = new SendGridService(key); string htmlBody = $@"<ul>From :{email.From}<li>To: {email.To}</li><li>Email: {email.Body}</li></ul>"; EmailMessage msg = new EmailMessage() { Body = htmlBody, Subject = "Winifred Osezuah", From = email.From, To = email.To }; string envPath = HttpRuntime.AppDomainAppPath; string fileName = $"{envPath}\\Log\\log-file.txt"; byte[] fileData = null; FileInfo fileInfo = new FileInfo(fileName); long imageFileLength = fileInfo.Length; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); fileData = br.ReadBytes((int)imageFileLength); messageSvc.SendMail(msg, true, fileName, fileData); return(RedirectToAction("Success", "LogError")); }
public MemoService(MeredithDbContext dbContext, IBackgroundJobClient backgroundJobClient, SendGridService sendGridService, EmailRecipientService emailRecipientService) { _dbContext = dbContext; _backgroundJobClient = backgroundJobClient; _sendGridService = sendGridService; _emailRecipientService = emailRecipientService; }
public AuthenticationController(UserManager <User> userManager, SignInManager <User> signInManager, IOptions <JwtOptions> jwtOptions, SendGridService sendGridService) { _userManager = userManager; _signInManager = signInManager; _sendGridService = sendGridService; _jwtOptions = jwtOptions.Value; }
private SendGridService GetSendGridService() { var apiKey = ""; var sendGridConifg = new SendGridConfig(apiKey); var service = new SendGridService(sendGridConifg); return(service); }
public JumpStartEmailJob(MeredithDbContext dbContext, SendGridService sendGridService, JumpStartEmailTemplateService jumpStartEmailTemplateService, JumpStartPdfJob jumpStartPdfJob) { _dbContext = dbContext; _sendGridService = sendGridService; _jumpStartEmailTemplateService = jumpStartEmailTemplateService; _jumpStartPdfJob = jumpStartPdfJob; }
public JumpStartEmailService(MeredithDbContext dbContext, SendGridService sendGridService, JumpStartEmailTemplateService jumpStartEmailTemplateService, JumpStartPdfService jumpStartPdfService) { _dbContext = dbContext; _sendGridService = sendGridService; _jumpStartEmailTemplateService = jumpStartEmailTemplateService; _jumpStartPdfService = jumpStartPdfService; }
public void SendTestEmailWithTwoAttachments() { SendGridService sendGridService = new SendGridService(_sendGridConfig); var response = sendGridService.Send("*****@*****.**", "SendTestEmailWithTwoAttachments Test Body", "SendTestEmailWithTwoAttachments Test Subject", _images); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Accepted); }
public ReservationService(MeredithDbContext meredithDbContext, SendGridService sendGridService, IBackgroundJobClient backgroundJobClient, UserManager userManager) { _meredithDbContext = meredithDbContext; _sendGridService = sendGridService; _backgroundJobClient = backgroundJobClient; _userManager = userManager; }
public TransactionalMailHelper(SendGridService sendGridService, IMailConfigStorage mailConfigStorage, WorkspaceAppService workspaceAppService) { _fromAddress = new EmailAddress("Team at Project Unicorn", "*****@*****.**"); _testEmailIndicator = AppSettings.Env == "Staging" || AppSettings.Env == "Development" ? "[TEST EMAIL] " : ""; _sendGridService = sendGridService; _mailConfig = new MailConfig(mailConfigStorage); _userStorage = new UserEntity(); _workspaceAppService = workspaceAppService; }
public ProjectLaunchShowcase(ILogger <ProjectLaunchShowcase> logger, IMailConfigStorage mailConfigStorage, IMessageQueue messageQueue) { _logger = logger; _mailConfig = new MailConfig(mailConfigStorage); _testEmailIndicator = AppSettings.Env == "Staging" || AppSettings.Env == "Development" ? "[TEST EMAIL] " : ""; _sendGridService = new SendGridService(); _userStorage = new UserEntity(); _fromAddress = new EmailAddress("Team at Project Unicorn", "*****@*****.**"); _messageQueue = messageQueue; }
public BookingOrchestrationClient( BookFlightService bookFlightService, BookHotelService bookHotelService, SendGridService sendGridService, IBookingConfiguration configuration) { _bookFlightService = bookFlightService; _bookHotelService = bookHotelService; _sendGridService = sendGridService; _configuration = configuration; }
public void SendTestEmailWithOneAttachment() { SendGridService sendGridService = new SendGridService(_sendGridConfig); var attachment = new Dictionary <string, string>() { { _images.FirstOrDefault().Key, _images.FirstOrDefault().Value } }; var response = sendGridService.Send("*****@*****.**", "SendTestEmailWithOneAttachment Test Body", "SendTestEmailWithOneAttachment Test Subject", attachment); Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Accepted); }
private void OnSendEmailClicked(object sender, EventArgs e) { string emailAddress = EmailAddress.Text; string customText = EmailCustomText.Text; SendGridService sendGridService = new SendGridService(GetSendGridConfig()); Dictionary <string, string> images = new Dictionary <string, string>() { { "TestImage1.png", @"..\Appx\Assets\Square44x44Logo.scale-200.png" } }; var response = sendGridService.Send(emailAddress, customText, "Instant PhotoBooth Image Delivery", images); DisplayAlert("Message Result", response.StatusCode.ToString(), "OK"); }
public async Task Send_Mail_Test() { var mail = new SendGridService(new SendGridMailServiceConfiguration() { ApiKey = Environment.GetEnvironmentVariable("SendGridApiKey") }); var mailResponse = await mail.Send( new System.Net.Mail.MailAddress(Environment.GetEnvironmentVariable("SendGridIntegrationTestEmail"), "Receiver display name"), new System.Net.Mail.MailAddress("*****@*****.**", "Sender display name"), "Integration test mail", "<b>Integration test mail"); Assert.AreEqual(mailResponse, true); }
private bool SendApplicationToDatabase(ApplyViewModel applyViewModel) { if (applyViewModel.ApplicationId > 0) { var application = _applicationData.FindById(applyViewModel.ApplicationId); if (application == null) { return(false); } application.Name = applyViewModel.Name; application.Phone = applyViewModel.Phone; application.CommunicationEmail = applyViewModel.CommunicationEmail; application.Info = applyViewModel.Info; application.CvFile = applyViewModel.CvFile; _applicationData.Update(application); } else { var jobOffer = _jobOfferData.FindById(applyViewModel.JobOfferId); if (jobOffer == null) { return(false); } var application = new Application(); application.UserEmail = User.FindFirst("emails").Value; application.ApplicationId = 0; application.JobOfferId = applyViewModel.JobOfferId; application.OfferName = jobOffer.Name; application.Name = applyViewModel.Name; application.Phone = applyViewModel.Phone; application.CommunicationEmail = applyViewModel.CommunicationEmail; application.Info = applyViewModel.Info; application.CvFile = applyViewModel.CvFile; _applicationData.Add(application); var hrEmail = _jobOfferData.GetHrEmail(applyViewModel.JobOfferId); if (hrEmail != null) { var apikey = _configuration["sendgridapikey"]; SendGridService.SendEmail(hrEmail, applyViewModel.OfferName, apikey, application.CvFile); } } _applicationData.Commit(); return(true); }
public AuthController ( SignInManager <ClassicGuildBankUser> signInManager, UserManager <ClassicGuildBankUser> userManager, GuildBankRepository repository, ILogger <AuthController> logger, IConfiguration configuration, SendGridService sendGridService ) { _signInManager = signInManager; _userManager = userManager; _logger = logger; _configuration = configuration; _sendGridService = sendGridService; _guildBankRepository = repository; }
public ProjectRecommendations(ILogger <ProjectRecommendations> logger, IMessageQueue messageQueue, IMailConfigStorage mailConfigStorage) { _logger = logger; _sendGridService = new SendGridService(); _userStorage = new UserEntity(); _projectStorage = new ProjectEntity(); _fromAddress = new EmailAddress("Team at Project Unicorn", "*****@*****.**"); // TODO: Read communication platform from database _communicationLogos = new Dictionary <string, string>() { { "discord", _discordLogoUrl }, { "slack", _slackLogoUrl } }; _messageQueue = messageQueue; _mailConfig = new MailConfig(mailConfigStorage); _testEmailIndicator = AppSettings.Env == "Staging" || AppSettings.Env == "Development" ? "[TEST EMAIL] " : ""; }
public async Task ReceiveEmailAsync_ShouldReturnCorrectResponse() { var configuration = Configuration.InitConfiguration(); var sendgridApiKey = configuration["Sendgrid:ApiKey"]; var options = new SendGridClientOptions(); options.ApiKey = sendgridApiKey; var sendGridClient = new SendGridClient(options.ApiKey); var sendGridService = new SendGridService(sendGridClient); var email = GlobalConstants.ApplicationEmail; var name = "Name"; var subject = "subject"; var content = "Some content"; var response = await sendGridService.ReceiveEmailAsync(email, name, subject, content); Assert.True(response.StatusCode.ToString() == "Accepted", ErrorMessage); }
public HttpResponseMessage SendEmail(EmailModel email) { try { if (!ModelState.IsValid) { return(this.Request.CreateResponse(HttpStatusCode.BadRequest, "your fields are not valid")); } string key = ConfigurationManager.AppSettings["Sendgrid.Key"]; SendGridService messageSvc = new SendGridService(key); string htmlBody = $@"<ul>From :{email.From}<li>To: {email.To}</li><li>Email: {email.Body}</li></ul>"; EmailMessage msg = new EmailMessage() { Body = htmlBody, Subject = "Winifred Osezuah", From = email.From, To = email.To }; string envPath = HttpRuntime.AppDomainAppPath; string fileName = $"{envPath}\\Log\\log-file.txt"; byte[] fileData = null; FileInfo fileInfo = new FileInfo(fileName); long imageFileLength = fileInfo.Length; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); fileData = br.ReadBytes((int)imageFileLength); messageSvc.SendMail(msg, true, fileName, fileData); return(this.Request.CreateResponse(HttpStatusCode.OK, "Successfully sent mail")); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <CommandResult <CommandEmptyResult> > Handle(ConfirmOrderCommand request, CancellationToken cancellationToken) { var order = _orderRepository.QueryAllIncluding(o => o.Items, o => o.DeliveryAddress, o => o.PickUpAddress, o => o.File).FirstOrDefault(a => a.Id == request.OrderId); if (order == null) { return(await Task.FromResult(CommandResult <CommandEmptyResult> .Fail("Fail to add bank reference to order - order does not exist."))); } var bankReference = $"{request.MerchantId};{request.TerminalId};{request.PurchaseTime};{request.OrderId};{request.Currency};{request.TotalAmount};"; if (bankReference == null || bankReference == "") { return(await Task.FromResult(CommandResult <CommandEmptyResult> .Fail("Cannot confirm without bank reference."))); } order.BankReferenceId = bankReference; order.Signature = request.Signature; order.Email = request.Email; order.PaymentMethod = "Plaćeno karticom"; _unitOfWork.SaveChanges(); var sendGrid = new SendGridService(order, _configuration); var success = await sendGrid.SendMailAsync(); order.File.Name = null; order.File.FileInBytes = null; _unitOfWork.SaveChanges(); if (!success) { return(await Task.FromResult(CommandResult <CommandEmptyResult> .Fail(new CommandEmptyResult()))); } return(await Task.FromResult(CommandResult <CommandEmptyResult> .Success(null))); }
public NewJumpStartEmailJob(MeredithDbContext dbContext, SendGridService sendGridService) { _dbContext = dbContext; _sendGridService = sendGridService; }
public UserInviteController(OregonTrailDBContext dbContext, UserManager <IdentityUser> userManager, IOptions <SendGridOptions> options) { DataService = new UserInviteDataService(dbContext); UserManager = userManager; SendGridEmailService = new SendGridService(options); }
public BaseTest() { Service = new SendGridService(SendGridApiKey); }
protected Default() { _sendGridService = new SendGridService(); }
public MemoJob(MeredithDbContext dbContext, SendGridService sendGridService) { _dbContext = dbContext; _sendGridService = sendGridService; }
public async Task <ActionResult> CreateProperty(PropertyView model) { if (ModelState.IsValid && model.SellerSigniture) { try { var config = new MapperConfiguration(cfg => { cfg.CreateMap <PropertyView, Property>(); }); IMapper mapper = config.CreateMapper(); Property NewProp = mapper.Map <PropertyView, Property>(model); NewProp.SellerID = User.Identity.GetUserId(); if (NewProp.TitleDeedPath == "") { NewProp.TitleDeedPath = "N/A"; } if (NewProp.BedRooms == null) { NewProp.BedRooms = 0; } if (NewProp.FloorSize == null) { NewProp.FloorSize = 0; } if (NewProp.YardSize == null) { NewProp.YardSize = 0; } if (NewProp.Reserve == null) { NewProp.Reserve = 0; } if (NewProp.Garages == null) { NewProp.Garages = 0; } if (NewProp.OpeningBid == null) { NewProp.OpeningBid = 0; } if (NewProp.TaxesAndRate == null) { NewProp.TaxesAndRate = 0; } if (NewProp.levies == null) { NewProp.levies = 0; } NewProp.MandateSingedDate = DateTime.Now; NewProp.MandateExpireDate = DateTime.Now.AddDays(90); NewProp.TaxesAndRates = FileController.PostFile(model.TaxesAndRates, "TaxesAndRates", "TaxesAndRates"); NewProp.PlansPath = FileController.PostFile(model.PlansPath, "Plans", "Plans"); // NewProp.TitleDeedPath = FileController.PostFile(model.TitleDeedPath, "Titledeeds", "Titledeeds"); NewProp.HOARules = FileController.PostFile(model.HOARules, "HOARules", "HOARules"); //Call Post Method Property ob = APIMethods.APIPost <Property>(NewProp, "Properties"); SendGridService ser = new SendGridService(); /*EmailMessageInfo msg = new EmailMessageInfo() { * FromEmailAddress = "*****@*****.**", * ToEmailAddress = model.Seller.SellerEmail, * EmailSubject ="New Property listing.", * EmailBody = "Property: Title-"+model.Title+"/n Address- "+model.Address+"/n Youre listing will be reviewed and you will be notified Accordingly." * }; * // await ser.Send(msg); * * EmailMessageInfo msgAdmin = new EmailMessageInfo() { * FromEmailAddress = "*****@*****.**", * ToEmailAddress = model.Seller.SellerEmail, * EmailSubject ="New Property listing.", * EmailBody = "Property: Title-"+model.Title+"/n Address- "+model.Address+"./n Property listed by "+model.Seller.FirtstName+" "+model.Seller.LastName * }; * await ser.Send(msgAdmin);*/ return(RedirectToAction("AddPhoto", new { id = ob.PropertyID })); } catch (Exception E) { throw new Exception(E.Message); } } else { return(View(model)); } }