選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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

Powered by TurnKey Linux.