public static Email BuildAssignCertificateEmail(Identity identity, Subscription subscription, byte[] cer) { string template = GetTemplate("AssignCertificate"); var emailMessage = new EmailMessage() { Body = Engine.Razor.RunCompile( template, "assignCertificateTemplate", null, new { User = identity.DisplayName }), To = identity.Email, Subject = string.Format("Azure Management Certificate"), Attachement = cer, AttachementName = "Management.cer" }; var email = new Email(new List<EmailMessage> { emailMessage }); return email; }
private RestRequest CreateEmailRequest(EmailMessage emailMessage) { var request = new RestRequest(); request.AddParameter("domain", "sandbox3280ff42a045437d9d190757b3b5caf2.mailgun.org", ParameterType.UrlSegment); request.Resource = "sandbox3280ff42a045437d9d190757b3b5caf2.mailgun.org/messages"; request.AddParameter("from", "*****@*****.**"); request.AddParameter("to", emailMessage.To); request.AddParameter("subject", emailMessage.Subject); request.AddParameter("html", emailMessage.Body); if (emailMessage.Attachement != null && emailMessage.AttachementName != null) { request.AddFile("attachment", emailMessage.Attachement, emailMessage.AttachementName, MediaTypeNames.Application.Octet); } request.Method = Method.POST; return request; }
public static Email BuildTemplateVMCaptured(TemplateVM templateVm, bool labCreated = false) { //TODO: finish! string fileName; string subject; if (labCreated) { fileName = "LabCreatedWithImage"; subject = string.Format("Your Lab \"{0}\" has been created", templateVm.VMLabel); } else { fileName = "TemplateImageUpdated"; subject = string.Format("Your Template Image \"{0}\" has been updated", templateVm.VMLabel); } string template = GetTemplate(fileName); var emailMessage = new EmailMessage() { Body = Engine.Razor.RunCompile( template, "vmCapturedTemplate", null, new { User = templateVm.Identity.FirstName, LabName = templateVm.VMLabel }), To = templateVm.Identity.Email, Subject = subject, }; var email = new Email(new List<EmailMessage> { emailMessage }); return email; }
public static Email BuildTemplateVMReady(TemplateVM templateVm) { string template = GetTemplate("TemplateVMReady"); var emailMessage = new EmailMessage() { Body = Engine.Razor.RunCompile( template, "vmReadyTemplate", null, new { User = templateVm.Identity.FirstName, UserName = string.Format(@"{0}\{1}", templateVm.VMName, templateVm.VMAdminUser), Password = templateVm.VMAdminPass, LabName = templateVm.VMLabel, RDPHost = templateVm.VMName + ":" + templateVm.VmRdpPort }), To = templateVm.Identity.Email, Subject = string.Format("Template Image VM for \"{0}\" is ready", templateVm.VMLabel), Attachement = BuildRdpAttachement(templateVm.VMName, templateVm.VmRdpPort), AttachementName = "trainingMachine.rdp" }; var email = new Email(new List<EmailMessage> { emailMessage }); return email; }
public static Email BuildSignUpEmail(Identity identity) { string template = GetTemplate("signup"); var emailMessage = new EmailMessage() { Body = Engine.Razor.RunCompile( template, "signupEmailTemplate", null, new { User = identity.DisplayName, Email = identity.Email }), To = "[email protected],[email protected],[email protected]", Subject = string.Format("User {0} just signup", identity.DisplayName), }; var email = new Email(new List<EmailMessage> { emailMessage }); return email; }