Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

254 rindas
14KB

  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. "allisonq@kentcommunications.com")
  53. End Function
  54. Private Function NewConfiguredMail()
  55. Dim smtpPort : smtpPort = GetAppSetting("SmtpPort")
  56. If Not IsNumeric(smtpPort) Then smtpPort = 25
  57. Dim mail : Set mail = CDOEmail()
  58. mail.SMTPServer = GetAppSetting("SmtpServer")
  59. mail.SMTPPort = CInt(smtpPort)
  60. mail.SMTPUsername = GetAppSetting("SmtpUsername")
  61. mail.SMTPPassword = GetAppSetting("SmtpPassword")
  62. mail.SMTPUseSSL = (LCase(GetAppSetting("SmtpUseSSL")) = "true")
  63. mail.From = GetAppSetting("SmtpFromAddress")
  64. Set NewConfiguredMail = mail
  65. End Function
  66. Private Function BuildOrderDetailsEmailBody(order, model)
  67. Dim html
  68. html = "<div style=""color:#7c3bc0; font-weight:800; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;"">Order Received</div>" & _
  69. "<h1 style=""color:#201a27; font-size:22px; margin:6px 0 4px; font-family:Arial, Helvetica, sans-serif;"">Thanks! We&rsquo;ve received your submission. A KCI representative will be in touch in the next 48 hours. If you don&rsquo;t see anything in your inbox, be sure to check your spam folder!</h1>" & _
  70. "<p style=""color:#6d6574; font-size:13px; margin:0 0 8px;"">Jurisdiction number <strong style=""color:#201a27;"">" & H(order("JurisdictionNumber")) & "</strong>" & _
  71. " &middot; submitted " & H(EmailDate(model.SubmittedAt)) & "</p>"
  72. html = html & EmailSection("Contact Information", _
  73. EmailRow("Contact Name", model.ContactName) & _
  74. EmailRow("Municipality", model.Municipality) & _
  75. EmailRow("Phone", model.Phone) & _
  76. EmailRow("Email", order("Email")))
  77. If IsTrue(model.PurpleWantsQuote) Then
  78. html = html & EmailSection("Purple Ballot Envelopes", _
  79. EmailRow("Permanent ballot list count", model.PurplePermanentBallotListCount) & _
  80. EmailRow("Envelope stock", LabelEnvelopeStock(model.PurpleEnvelopeStock)) & _
  81. EmailRow("Print option", LabelPrintOption(model.PurplePrintOption)) & _
  82. EmailRow("Print style", LabelPrintStyle(model.PurplePrintStyle)) & _
  83. EmailRow("Color coding by", LabelColorCodingBy(model.PurpleColorCodingBy)) & _
  84. EmailRow("Number of precincts", model.PurplePrecinctCount) & _
  85. EmailRow("Colors requested", model.PurpleColorNames) & _
  86. EmailRow("Track with TrackMI Ballot", EmailYesNo(model.PurpleTrackMIBallot)) & _
  87. EmailRow("Extra envelopes requested", model.PurpleExtraEnvelopeQty))
  88. End If
  89. If Not IsNull(model.BlueWantsQuote) Then
  90. Dim blueProviderLine
  91. blueProviderLine = LabelPurpleBlueProvider(model.PurpleBlueProvider)
  92. If blueProviderLine = "Other" And Len(Trim(model.PurpleBlueProviderOther & "")) > 0 Then
  93. blueProviderLine = model.PurpleBlueProviderOther
  94. End If
  95. ' City/permit number are collected for an own-organization permit - a permit
  96. ' lookup can't be done from the nonprofit authorization code alone.
  97. Dim bluePermitLine
  98. bluePermitLine = ""
  99. If LabelPermitOwnership(model.BluePermitOwnership) = "My organization's permit" Then
  100. bluePermitLine = bluePermitLine & _
  101. EmailRow("City of permit holder", model.BluePermitCity) & _
  102. EmailRow("Permit number", model.BluePermitNumber)
  103. End If
  104. html = html & EmailSection("Blue AV Envelopes", _
  105. EmailRow("Purchasing blue envelopes from KCI", EmailYesNo(model.BlueWantsQuote)) & _
  106. EmailRow("Additional office copies", model.BlueWantsOfficeCopies) & _
  107. EmailRow("Additional office copies requested", model.BlueOfficeCopiesQty) & _
  108. EmailRow("Blue envelope provider", blueProviderLine) & _
  109. EmailRow("Print permit", EmailYesNo(model.BluePrintPermit)) & _
  110. EmailRow("Permit ownership", LabelPermitOwnership(model.BluePermitOwnership)) & _
  111. EmailRow("Confirmed nonprofit status with USPS", LabelNonprofitStatus(model.BlueHasNonprofitStatus)) & _
  112. bluePermitLine)
  113. End If
  114. If IsTrue(model.MailingWantsService) Then
  115. Dim mailingAuthCodeLine
  116. mailingAuthCodeLine = ""
  117. If CStr(model.MailingHasNonprofitStatus & "") = "Yes" Then
  118. If IsTrue(model.MailingNonprofitAuthCodeUnknown) Then
  119. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", "Unknown - customer needs help")
  120. Else
  121. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", model.MailingNonprofitAuthCode)
  122. End If
  123. End If
  124. html = html & EmailSection("Ballot Mailing Service", _
  125. EmailRow("Postage", LabelPostageOption(model.MailingPostageOption)) & _
  126. EmailRow("Nonprofit status with USPS", LabelNonprofitStatus(model.MailingHasNonprofitStatus)) & _
  127. mailingAuthCodeLine & _
  128. EmailRow("Estimated quantity", model.MailingEstimatedQuantity) & _
  129. EmailRow("Preferred pickup date", EmailDate(model.MailingPickupDate)))
  130. End If
  131. If NumOrZero(model.SecrecySleevesQty) > 0 Or NumOrZero(model.IVotedStickerRolls) > 0 Or NumOrZero(model.FutureVoterStickerRolls) > 0 Or Len(Trim(model.SpecialRequests & "")) > 0 Then
  132. html = html & EmailSection("Additional Election Items", _
  133. EmailRow("Secrecy sleeves (quantity)", model.SecrecySleevesQty) & _
  134. EmailRow("""I Voted"" stickers (rolls of 250)", model.IVotedStickerRolls) & _
  135. EmailRow("""Future Voter"" stickers (rolls of 500)", model.FutureVoterStickerRolls) & _
  136. EmailRow("Special requests", model.SpecialRequests))
  137. End If
  138. html = html & "<p style=""color:#6d6574; font-size:12px; margin-top:24px;"">Questions about this order? Just reply to this email.</p>"
  139. BuildOrderDetailsEmailBody = EmailShell(html)
  140. End Function
  141. ' Wraps inner body HTML in the same header/footer chrome used across the website - the
  142. ' navy KCI Election Printing bar (matching the site header/footer) and white content card.
  143. Private Function EmailShell(innerHtml)
  144. Dim logoUrl : logoUrl = Routes().AppURL & "images/KCI%20ELECTION%20printing%20(white).png"
  145. EmailShell = "<!doctype html><html><body style=""margin:0; padding:0; background:#faf7fd; font-family:Arial, Helvetica, sans-serif;"">" & _
  146. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""background:#faf7fd; padding:24px 0;""><tr><td align=""center"">" & _
  147. "<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);"">" & _
  148. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  149. "<img src=""" & H(logoUrl) & """ alt=""KCI Election Printing"" width=""160"" style=""display:block; margin:0 auto; height:auto; max-width:160px;"" />" & _
  150. "</td></tr>" & _
  151. "<tr><td style=""padding:32px;"">" & innerHtml & "</td></tr>" & _
  152. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  153. "<div style=""color:#ffffff; font-size:12px; font-weight:700;"">KCI Election Printing</div>" & _
  154. "<div style=""color:rgba(255,255,255,0.75); font-size:11px; margin-top:4px;"">616.957.2120 &middot; info@kentcommunications.com</div>" & _
  155. "</td></tr>" & _
  156. "</table></td></tr></table></body></html>"
  157. End Function
  158. Private Function EmailSection(sectionTitle, rowsHtml)
  159. If Len(rowsHtml) = 0 Then
  160. EmailSection = ""
  161. Else
  162. 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;"">" & _
  163. H(sectionTitle) & "</h2>" & _
  164. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"">" & rowsHtml & "</table>"
  165. End If
  166. End Function
  167. Private Function EmailRow(label, value)
  168. If Len(Trim(value & "")) = 0 Then
  169. EmailRow = ""
  170. Else
  171. EmailRow = "<tr>" & _
  172. "<td style=""padding:6px 0; color:#6d6574; font-size:13px; width:45%; vertical-align:top;"">" & H(label) & "</td>" & _
  173. "<td style=""padding:6px 0; color:#201a27; font-size:13px; font-weight:600;"">" & H(value) & "</td>" & _
  174. "</tr>"
  175. End If
  176. End Function
  177. ' Null-safe boolean check for gating whole sections - a section's top-level "do you want
  178. ' this?" question isn't marked required client-side, so it may be missing (Null) rather
  179. ' than explicitly false.
  180. Private Function IsTrue(v)
  181. If IsNull(v) Then
  182. IsTrue = False
  183. Else
  184. IsTrue = CBool(v)
  185. End If
  186. End Function
  187. Private Function EmailYesNo(v)
  188. If IsNull(v) Then
  189. EmailYesNo = ""
  190. ElseIf CBool(v) Then
  191. EmailYesNo = "Yes"
  192. Else
  193. EmailYesNo = "No"
  194. End If
  195. End Function
  196. Private Function EmailDate(v)
  197. If IsNull(v) Then
  198. EmailDate = ""
  199. Else
  200. On Error Resume Next
  201. EmailDate = MonthName(Month(v)) & " " & Day(v) & ", " & Year(v)
  202. If Err.Number <> 0 Then EmailDate = ""
  203. Err.Clear
  204. On Error GoTo 0
  205. End If
  206. End Function
  207. Private Function NumOrZero(v)
  208. If IsNull(v) Or Not IsNumeric(v) Then
  209. NumOrZero = 0
  210. Else
  211. NumOrZero = CDbl(v)
  212. End If
  213. End Function
  214. End Class
  215. Dim OrderMailer_Class__Singleton
  216. Function OrderMailer()
  217. If IsEmpty(OrderMailer_Class__Singleton) Then
  218. Set OrderMailer_Class__Singleton = New OrderMailer_Class
  219. End If
  220. Set OrderMailer = OrderMailer_Class__Singleton
  221. End Function
  222. %>

Powered by TurnKey Linux.