public async Task <GeneralResponse> SendEmail(Applicant applicant, JobPosting jobPosting) { var numOfApplication = applicant.Applications.Count; using (var client = new AmazonSimpleEmailServiceClient(new EnvironmentVariablesAWSCredentials(), RegionEndpoint.USWest2)) { var sendRequest = new SendEmailRequest { Source = ConstantStrings.EMAIL_SENDER, Destination = new Destination { ToAddresses = new List <string> { applicant.User.Email } }, Message = new Message { Subject = new Content("New job post application"), Body = new Body { Html = new Content { Charset = "UTF-8", Data = _emailTemplate.NewApplicantAppliedTemplate(applicant, jobPosting) }, Text = new Content { Charset = "UTF-8", Data = $"Congratulations on your {numOfApplication}{(numOfApplication == 1 ? "st" : numOfApplication == 2 ? "nd" : numOfApplication == 3 ? "rd" : "th")} application, {applicant.User.FirstName}!" + "You have just applied for the following Job:" + $"Position: {jobPosting.Title}" + "You can see all your job applications on http://dev-docker:9014/applicant/my-applications" + "Sincerely, HRHunters" } } }, }; var generalResponse = new GeneralResponse(); var emailResponse = new SendEmailResponse(); try { emailResponse = await client.SendEmailAsync(sendRequest); generalResponse.Succeeded = true; return(generalResponse); } catch (Exception e) { return(generalResponse.ErrorHandling <EmailSenderManager>(emailResponse.MessageId, objects: (sendRequest, e))); } } }