% '======================================================================================================================= ' Order-related outbound email: the "continue your order" link and the order-details ' confirmation sent after SubmitOrderDetails. '======================================================================================================================= Class OrderMailer_Class Public Sub SendContinuationEmail(email, token) Dim continueUrl continueUrl = Routes().AppURL & "order/continue?token=" & Server.URLEncode(token) Dim inner inner = "
Click the button below to pick up where you left off.
" & _ "" & _ "Or copy and paste this link into your browser:
" & H(continueUrl) & "
This link expires in " & H(GetAppSetting("OrderTokenExpirationHours")) & " hours and can only be used once.
" Dim mail : Set mail = NewConfiguredMail() mail.Subject = "Continue your Purple Envelope order" mail.IsBodyHTML = True mail.Body = EmailShell(inner) mail.AddRecipient "To", email mail.Send End Sub ' Best-effort: the order is already safely persisted by the time a caller reaches this - ' an SMTP hiccup here should not turn a successful submission into a failed one. Public Sub SendOrderDetailsEmail(order, model) On Error Resume Next Dim mail : Set mail = NewConfiguredMail() mail.Subject = "Your Purple Envelope order details - Jurisdiction " & order("JurisdictionNumber") mail.IsBodyHTML = True mail.Body = BuildOrderDetailsEmailBody(order, model) mail.AddRecipient "To", order("Email") mail.Send Err.Clear On Error GoTo 0 End Sub '------------------------------------------------------------------------------------------------------------------- ' Private helpers '------------------------------------------------------------------------------------------------------------------- Private Function NewConfiguredMail() Dim smtpPort : smtpPort = GetAppSetting("SmtpPort") If Not IsNumeric(smtpPort) Then smtpPort = 25 Dim mail : Set mail = CDOEmail() mail.SMTPServer = GetAppSetting("SmtpServer") mail.SMTPPort = CInt(smtpPort) mail.SMTPUsername = GetAppSetting("SmtpUsername") mail.SMTPPassword = GetAppSetting("SmtpPassword") mail.SMTPUseSSL = (LCase(GetAppSetting("SmtpUseSSL")) = "true") mail.From = GetAppSetting("SmtpFromAddress") Set NewConfiguredMail = mail End Function Private Function BuildOrderDetailsEmailBody(order, model) Dim html html = "Jurisdiction number " & H(order("JurisdictionNumber")) & "" & _ " · submitted " & H(EmailDate(model.SubmittedAt)) & "
" html = html & EmailSection("Contact Information", _ EmailRow("Contact Name", model.ContactName) & _ EmailRow("Municipality", model.Municipality) & _ EmailRow("Phone", model.Phone)) If IsTrue(model.PurpleWantsQuote) Then html = html & EmailSection("Purple Ballot Envelopes", _ EmailRow("Permanent ballot list count", model.PurplePermanentBallotListCount) & _ EmailRow("Envelope stock", LabelEnvelopeStock(model.PurpleEnvelopeStock)) & _ EmailRow("Print option", LabelPrintOption(model.PurplePrintOption)) & _ EmailRow("Print style", LabelPrintStyle(model.PurplePrintStyle)) & _ EmailRow("Color coding by", LabelColorCodingBy(model.PurpleColorCodingBy)) & _ EmailRow("Number of precincts", model.PurplePrecinctCount) & _ EmailRow("Colors requested", model.PurpleColorNames) & _ EmailRow("Track with TrackMI Ballot", EmailYesNo(model.PurpleTrackMIBallot)) & _ EmailRow("Extra envelopes requested", model.PurpleExtraEnvelopeQty)) End If If Not IsNull(model.BlueWantsQuote) Then Dim blueProviderLine blueProviderLine = LabelPurpleBlueProvider(model.PurpleBlueProvider) If blueProviderLine = "Other" And Len(Trim(model.PurpleBlueProviderOther & "")) > 0 Then blueProviderLine = model.PurpleBlueProviderOther End If ' City/permit number are collected for an own-organization permit - a permit ' lookup can't be done from the nonprofit authorization code alone. Dim bluePermitLine bluePermitLine = "" If LabelPermitOwnership(model.BluePermitOwnership) = "My organization's permit" Then bluePermitLine = bluePermitLine & _ EmailRow("City of permit holder", model.BluePermitCity) & _ EmailRow("Permit number", model.BluePermitNumber) End If html = html & EmailSection("Blue AV Envelopes", _ EmailRow("Purchasing blue envelopes from KCI", EmailYesNo(model.BlueWantsQuote)) & _ EmailRow("Blue envelope provider", blueProviderLine) & _ EmailRow("Print permit", EmailYesNo(model.BluePrintPermit)) & _ EmailRow("Permit ownership", LabelPermitOwnership(model.BluePermitOwnership)) & _ EmailRow("Confirmed nonprofit status with USPS", LabelNonprofitStatus(model.BlueHasNonprofitStatus)) & _ bluePermitLine) End If If IsTrue(model.MailingWantsService) Then Dim mailingAuthCodeLine mailingAuthCodeLine = "" If CStr(model.MailingHasNonprofitStatus & "") = "Yes" Then If IsTrue(model.MailingNonprofitAuthCodeUnknown) Then mailingAuthCodeLine = EmailRow("Nonprofit authorization code", "Unknown - customer needs help") Else mailingAuthCodeLine = EmailRow("Nonprofit authorization code", model.MailingNonprofitAuthCode) End If End If html = html & EmailSection("Ballot Mailing Service", _ EmailRow("Postage", LabelPostageOption(model.MailingPostageOption)) & _ EmailRow("Nonprofit status with USPS", LabelNonprofitStatus(model.MailingHasNonprofitStatus)) & _ mailingAuthCodeLine & _ EmailRow("Estimated quantity", model.MailingEstimatedQuantity) & _ EmailRow("Preferred pickup date", EmailDate(model.MailingPickupDate))) End If If NumOrZero(model.SecrecySleevesQty) > 0 Or NumOrZero(model.IVotedStickerRolls) > 0 Or NumOrZero(model.FutureVoterStickerRolls) > 0 Or Len(Trim(model.SpecialRequests & "")) > 0 Then html = html & EmailSection("Additional Election Items", _ EmailRow("Secrecy sleeves (quantity)", model.SecrecySleevesQty) & _ EmailRow("""I Voted"" stickers (rolls of 250)", model.IVotedStickerRolls) & _ EmailRow("""Future Voter"" stickers (rolls of 500)", model.FutureVoterStickerRolls) & _ EmailRow("Special requests", model.SpecialRequests)) End If html = html & "Questions about this order? Just reply to this email.
" BuildOrderDetailsEmailBody = EmailShell(html) End Function ' Wraps inner body HTML in the same header/footer chrome used across the website - the ' navy KCI Election Printing bar (matching the site header/footer) and white content card. Private Function EmailShell(innerHtml) Dim logoUrl : logoUrl = Routes().AppURL & "images/KCI%20ELECTION%20printing%20(white).png" EmailShell = "" & _ "" & _
"
|