Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

253 lignes
13KB

  1. <%
  2. '=======================================================================================================================
  3. ' Order-related outbound email: the "continue your order" link and the order-details
  4. ' confirmation sent after SubmitOrderDetails.
  5. '=======================================================================================================================
  6. Class OrderMailer_Class
  7. Public Sub SendContinuationEmail(email, token)
  8. Dim continueUrl
  9. continueUrl = Routes().AppURL & "order/continue?token=" & Server.URLEncode(token)
  10. Dim inner
  11. inner = "<div style=""color:#7c3bc0; font-weight:800; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;"">Order Request Received</div>" & _
  12. "<h1 style=""color:#201a27; font-size:22px; margin:6px 0 12px; font-family:Arial, Helvetica, sans-serif;"">Continue your election materials order</h1>" & _
  13. "<p style=""color:#6d6574; font-size:13px; margin:0 0 20px;"">Click the button below to pick up where you left off.</p>" & _
  14. "<p style=""margin:0 0 20px;""><a href=""" & H(continueUrl) & """ style=""display:inline-block; background:#6529a0; color:#ffffff; font-weight:700; font-size:14px; padding:12px 28px; border-radius:10px; text-decoration:none;"">Continue your order</a></p>" & _
  15. "<p style=""color:#6d6574; font-size:12px; margin:0;"">Or copy and paste this link into your browser:<br /><a href=""" & H(continueUrl) & """ style=""color:#6529a0;"">" & H(continueUrl) & "</a></p>" & _
  16. "<p style=""color:#6d6574; font-size:12px; margin-top:16px;"">This link expires in " & H(GetAppSetting("OrderTokenExpirationHours")) & " hours and can only be used once.</p>"
  17. Dim mail : Set mail = NewConfiguredMail()
  18. mail.Subject = "Continue your Purple Envelope order"
  19. mail.IsBodyHTML = True
  20. mail.Body = EmailShell(inner)
  21. mail.AddRecipient "To", email
  22. mail.Send
  23. End Sub
  24. ' Best-effort: the order is already safely persisted by the time a caller reaches this -
  25. ' an SMTP hiccup here should not turn a successful submission into a failed one.
  26. Public Sub SendOrderDetailsEmail(order, model)
  27. On Error Resume Next
  28. Dim mail : Set mail = NewConfiguredMail()
  29. mail.Subject = "Your Purple Envelope order details - Jurisdiction " & order("JurisdictionNumber")
  30. mail.IsBodyHTML = True
  31. mail.Body = BuildOrderDetailsEmailBody(order, model)
  32. mail.AddRecipient "To", order("Email")
  33. Dim ccAddress, ccAddresses
  34. ccAddresses = OrderReceivedCcAddresses()
  35. For Each ccAddress In ccAddresses
  36. mail.AddRecipient "Cc", ccAddress
  37. Next
  38. mail.Send
  39. Err.Clear
  40. On Error GoTo 0
  41. End Sub
  42. '-------------------------------------------------------------------------------------------------------------------
  43. ' Private helpers
  44. '-------------------------------------------------------------------------------------------------------------------
  45. ' Staff addresses CC'd on every "order received" confirmation email.
  46. Private Function OrderReceivedCcAddresses()
  47. OrderReceivedCcAddresses = Array( _
  48. "natascham@kentcommunications.com", _
  49. "erickaw@kentcommunications.com", _
  50. "danielc@kentcommunications.com", _
  51. "katelyne@kentcommunications.com")
  52. End Function
  53. Private Function NewConfiguredMail()
  54. Dim smtpPort : smtpPort = GetAppSetting("SmtpPort")
  55. If Not IsNumeric(smtpPort) Then smtpPort = 25
  56. Dim mail : Set mail = CDOEmail()
  57. mail.SMTPServer = GetAppSetting("SmtpServer")
  58. mail.SMTPPort = CInt(smtpPort)
  59. mail.SMTPUsername = GetAppSetting("SmtpUsername")
  60. mail.SMTPPassword = GetAppSetting("SmtpPassword")
  61. mail.SMTPUseSSL = (LCase(GetAppSetting("SmtpUseSSL")) = "true")
  62. mail.From = GetAppSetting("SmtpFromAddress")
  63. Set NewConfiguredMail = mail
  64. End Function
  65. Private Function BuildOrderDetailsEmailBody(order, model)
  66. Dim html
  67. html = "<div style=""color:#7c3bc0; font-weight:800; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;"">Order Received</div>" & _
  68. "<h1 style=""color:#201a27; font-size:22px; margin:6px 0 4px; font-family:Arial, Helvetica, sans-serif;"">Thanks! We've received your order details.</h1>" & _
  69. "<p style=""color:#6d6574; font-size:13px; margin:0 0 8px;"">Jurisdiction number <strong style=""color:#201a27;"">" & H(order("JurisdictionNumber")) & "</strong>" & _
  70. " &middot; submitted " & H(EmailDate(model.SubmittedAt)) & "</p>"
  71. html = html & EmailSection("Contact Information", _
  72. EmailRow("Contact Name", model.ContactName) & _
  73. EmailRow("Municipality", model.Municipality) & _
  74. EmailRow("Phone", model.Phone) & _
  75. EmailRow("Email", order("Email")))
  76. If IsTrue(model.PurpleWantsQuote) Then
  77. html = html & EmailSection("Purple Ballot Envelopes", _
  78. EmailRow("Permanent ballot list count", model.PurplePermanentBallotListCount) & _
  79. EmailRow("Envelope stock", LabelEnvelopeStock(model.PurpleEnvelopeStock)) & _
  80. EmailRow("Print option", LabelPrintOption(model.PurplePrintOption)) & _
  81. EmailRow("Print style", LabelPrintStyle(model.PurplePrintStyle)) & _
  82. EmailRow("Color coding by", LabelColorCodingBy(model.PurpleColorCodingBy)) & _
  83. EmailRow("Number of precincts", model.PurplePrecinctCount) & _
  84. EmailRow("Colors requested", model.PurpleColorNames) & _
  85. EmailRow("Track with TrackMI Ballot", EmailYesNo(model.PurpleTrackMIBallot)) & _
  86. EmailRow("Extra envelopes requested", model.PurpleExtraEnvelopeQty))
  87. End If
  88. If Not IsNull(model.BlueWantsQuote) Then
  89. Dim blueProviderLine
  90. blueProviderLine = LabelPurpleBlueProvider(model.PurpleBlueProvider)
  91. If blueProviderLine = "Other" And Len(Trim(model.PurpleBlueProviderOther & "")) > 0 Then
  92. blueProviderLine = model.PurpleBlueProviderOther
  93. End If
  94. ' City/permit number are collected for an own-organization permit - a permit
  95. ' lookup can't be done from the nonprofit authorization code alone.
  96. Dim bluePermitLine
  97. bluePermitLine = ""
  98. If LabelPermitOwnership(model.BluePermitOwnership) = "My organization's permit" Then
  99. bluePermitLine = bluePermitLine & _
  100. EmailRow("City of permit holder", model.BluePermitCity) & _
  101. EmailRow("Permit number", model.BluePermitNumber)
  102. End If
  103. html = html & EmailSection("Blue AV Envelopes", _
  104. EmailRow("Purchasing blue envelopes from KCI", EmailYesNo(model.BlueWantsQuote)) & _
  105. EmailRow("Additional office copies", model.BlueWantsOfficeCopies) & _
  106. EmailRow("Additional office copies requested", model.BlueOfficeCopiesQty) & _
  107. EmailRow("Blue envelope provider", blueProviderLine) & _
  108. EmailRow("Print permit", EmailYesNo(model.BluePrintPermit)) & _
  109. EmailRow("Permit ownership", LabelPermitOwnership(model.BluePermitOwnership)) & _
  110. EmailRow("Confirmed nonprofit status with USPS", LabelNonprofitStatus(model.BlueHasNonprofitStatus)) & _
  111. bluePermitLine)
  112. End If
  113. If IsTrue(model.MailingWantsService) Then
  114. Dim mailingAuthCodeLine
  115. mailingAuthCodeLine = ""
  116. If CStr(model.MailingHasNonprofitStatus & "") = "Yes" Then
  117. If IsTrue(model.MailingNonprofitAuthCodeUnknown) Then
  118. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", "Unknown - customer needs help")
  119. Else
  120. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", model.MailingNonprofitAuthCode)
  121. End If
  122. End If
  123. html = html & EmailSection("Ballot Mailing Service", _
  124. EmailRow("Postage", LabelPostageOption(model.MailingPostageOption)) & _
  125. EmailRow("Nonprofit status with USPS", LabelNonprofitStatus(model.MailingHasNonprofitStatus)) & _
  126. mailingAuthCodeLine & _
  127. EmailRow("Estimated quantity", model.MailingEstimatedQuantity) & _
  128. EmailRow("Preferred pickup date", EmailDate(model.MailingPickupDate)))
  129. End If
  130. If NumOrZero(model.SecrecySleevesQty) > 0 Or NumOrZero(model.IVotedStickerRolls) > 0 Or NumOrZero(model.FutureVoterStickerRolls) > 0 Or Len(Trim(model.SpecialRequests & "")) > 0 Then
  131. html = html & EmailSection("Additional Election Items", _
  132. EmailRow("Secrecy sleeves (quantity)", model.SecrecySleevesQty) & _
  133. EmailRow("""I Voted"" stickers (rolls of 250)", model.IVotedStickerRolls) & _
  134. EmailRow("""Future Voter"" stickers (rolls of 500)", model.FutureVoterStickerRolls) & _
  135. EmailRow("Special requests", model.SpecialRequests))
  136. End If
  137. html = html & "<p style=""color:#6d6574; font-size:12px; margin-top:24px;"">Questions about this order? Just reply to this email.</p>"
  138. BuildOrderDetailsEmailBody = EmailShell(html)
  139. End Function
  140. ' Wraps inner body HTML in the same header/footer chrome used across the website - the
  141. ' navy KCI Election Printing bar (matching the site header/footer) and white content card.
  142. Private Function EmailShell(innerHtml)
  143. Dim logoUrl : logoUrl = Routes().AppURL & "images/KCI%20ELECTION%20printing%20(white).png"
  144. EmailShell = "<!doctype html><html><body style=""margin:0; padding:0; background:#faf7fd; font-family:Arial, Helvetica, sans-serif;"">" & _
  145. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""background:#faf7fd; padding:24px 0;""><tr><td align=""center"">" & _
  146. "<table role=""presentation"" width=""600"" cellpadding=""0"" cellspacing=""0"" style=""background:#ffffff; border-radius:12px; overflow:hidden; box-shadow:0 4px 16px rgba(36,16,58,0.08);"">" & _
  147. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  148. "<img src=""" & H(logoUrl) & """ alt=""KCI Election Printing"" width=""160"" style=""display:block; margin:0 auto; height:auto; max-width:160px;"" />" & _
  149. "</td></tr>" & _
  150. "<tr><td style=""padding:32px;"">" & innerHtml & "</td></tr>" & _
  151. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  152. "<div style=""color:#ffffff; font-size:12px; font-weight:700;"">KCI Election Printing</div>" & _
  153. "<div style=""color:rgba(255,255,255,0.75); font-size:11px; margin-top:4px;"">616.957.2120 &middot; info@kentcommunications.com</div>" & _
  154. "</td></tr>" & _
  155. "</table></td></tr></table></body></html>"
  156. End Function
  157. Private Function EmailSection(sectionTitle, rowsHtml)
  158. If Len(rowsHtml) = 0 Then
  159. EmailSection = ""
  160. Else
  161. EmailSection = "<h2 style=""color:#4d1d78; font-size:14px; margin:24px 0 8px; padding-top:16px; border-top:1px solid #f0e7f8; font-family:Arial, Helvetica, sans-serif;"">" & _
  162. H(sectionTitle) & "</h2>" & _
  163. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"">" & rowsHtml & "</table>"
  164. End If
  165. End Function
  166. Private Function EmailRow(label, value)
  167. If Len(Trim(value & "")) = 0 Then
  168. EmailRow = ""
  169. Else
  170. EmailRow = "<tr>" & _
  171. "<td style=""padding:6px 0; color:#6d6574; font-size:13px; width:45%; vertical-align:top;"">" & H(label) & "</td>" & _
  172. "<td style=""padding:6px 0; color:#201a27; font-size:13px; font-weight:600;"">" & H(value) & "</td>" & _
  173. "</tr>"
  174. End If
  175. End Function
  176. ' Null-safe boolean check for gating whole sections - a section's top-level "do you want
  177. ' this?" question isn't marked required client-side, so it may be missing (Null) rather
  178. ' than explicitly false.
  179. Private Function IsTrue(v)
  180. If IsNull(v) Then
  181. IsTrue = False
  182. Else
  183. IsTrue = CBool(v)
  184. End If
  185. End Function
  186. Private Function EmailYesNo(v)
  187. If IsNull(v) Then
  188. EmailYesNo = ""
  189. ElseIf CBool(v) Then
  190. EmailYesNo = "Yes"
  191. Else
  192. EmailYesNo = "No"
  193. End If
  194. End Function
  195. Private Function EmailDate(v)
  196. If IsNull(v) Then
  197. EmailDate = ""
  198. Else
  199. On Error Resume Next
  200. EmailDate = MonthName(Month(v)) & " " & Day(v) & ", " & Year(v)
  201. If Err.Number <> 0 Then EmailDate = ""
  202. Err.Clear
  203. On Error GoTo 0
  204. End If
  205. End Function
  206. Private Function NumOrZero(v)
  207. If IsNull(v) Or Not IsNumeric(v) Then
  208. NumOrZero = 0
  209. Else
  210. NumOrZero = CDbl(v)
  211. End If
  212. End Function
  213. End Class
  214. Dim OrderMailer_Class__Singleton
  215. Function OrderMailer()
  216. If IsEmpty(OrderMailer_Class__Singleton) Then
  217. Set OrderMailer_Class__Singleton = New OrderMailer_Class
  218. End If
  219. Set OrderMailer = OrderMailer_Class__Singleton
  220. End Function
  221. %>

Powered by TurnKey Linux.