You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
14 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace EasyBL.WEBAPP.ShowEasy
  7. {
  8. class EmailTemplate
  9. {
  10. public string MailHeader() {
  11. StringBuilder sb = new StringBuilder();
  12. sb.Append("<!DOCTYPE html>");
  13. sb.Append("<html lang=\"en\" xmlns = \"http://www.w3.org/1999/xhtml\" xmlns: o = \"urn:schemas-microsoft-com:office:office\" xmlns: v = \"urn:schemas-microsoft-com:vml\"> ");
  14. //Head
  15. sb.Append("<head>");
  16. sb.Append("<meta charset=\"utf-8\" />");
  17. sb.Append("<meta name=\"viewport\" content=\"width = device-width\" />");
  18. sb.Append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE = edge\" />");
  19. sb.Append("<meta name=\"x-apple-disable-message-reformatting\" />");
  20. sb.Append("<meta name = \"format-detection\" content = \"telephone=no,address=no,email=no,date=no,url=no\" /> ");
  21. return sb.ToString();
  22. }
  23. public string MailCSS()
  24. {
  25. StringBuilder sb = new StringBuilder();
  26. //CSS Reset Style
  27. sb.Append("<style>");
  28. sb.Append("html,body {margin: 0 auto !important;padding: 0 !important;height: 100% !important;width: 100% !important;}");
  29. //Stops email clients resizing small text
  30. sb.Append("* {-ms-text-size-adjust: 100 %;-webkit-text-size-adjust: 100%;}");
  31. //Centers email on Android 4.4
  32. sb.Append("div[style*=\"margin: 16px 0\"] {margin: 0!important;}");
  33. //Stops Outlook from adding extra spacing to tables
  34. sb.Append("table,td {mso-table-lspace: 0pt !important;mso-table-rspace: 0pt !important;}");
  35. sb.Append("table {border: 0;border-spacing: 0;border-collapse: collapse;}");
  36. //Forces Samsung Android mail clients to use the entire viewport.
  37. sb.Append("#MessageViewBody,#MessageWebViewDiv {width: 100% !important;}");
  38. sb.Append("img {-ms-interpolation-mode: bicubic;}");
  39. //Prevents Windows 10 Mail from underlining links despite inline CSS. Styles for underlined links should be inline.
  40. sb.Append("a {text-decoration: none;}");
  41. //A work-around for email clients automatically linking certain text strings.
  42. sb.Append("a[x-apple-data-detectors],.unstyle-auto-detected-links a,.aBn {border - bottom: 0 !important;cursor: default !important;color: inherit !important;text-decoration: none !important;font - size: inherit !important;font-family: inherit !important;font-weight: inherit !important;line-height: inherit !important;}");
  43. //Gmail、Samsung Mail
  44. sb.Append("u + #body a,#MessageViewBody a{color: inherit;text-decoration: none;font-size: inherit;font-family: inherit;font-weight: inherit;line-height: inherit;}");
  45. //Prevents Gmail from changing the text color in conversation threads.
  46. sb.Append(".im {color: inherit !important;}");
  47. //Prevents Gmail from displaying an download button on large, non-linked images
  48. sb.Append(".a6S {display: none !important;opacity: 0.01 !important;}");
  49. //If the above doesn't work, add a .g-img class to any image in question.
  50. sb.Append("img.g-img + div {display: none !important;}");
  51. //RWD
  52. //Removes right gutter in Gmail iOS app: https://github.com/TedGoas/Cerberus/issues/89
  53. //Create one of these media queries for each additional viewport size you'd like to fix
  54. sb.Append("@media only screen and (min-device-width: 320px) and (max-device-width: 374px) {u ~ div.email-container {min-width: 320px !important;}}");
  55. sb.Append("@media only screen and (min-device-width: 375px) and (max-device-width: 413px) {u ~ div.email-container {min-width: 375px !important;}}");
  56. sb.Append("@media only screen and (min-device-width: 414px) {u ~ div.email-container {min-width: 414px !important;}");
  57. sb.Append("</style>");
  58. //CSS Style
  59. //Hover styles for buttons and tags
  60. sb.Append("<style>");
  61. sb.Append(".s-btn__primary:hover {backgbackground: #eff0f1 !important;border-color: #eff0f1 !important;}");
  62. sb.Append(".s-btn__outlined:hover {background: rgba(0, 119, 204, 0.05) !important;color: #faae69 !important;}");
  63. sb.Append(".s-tag:hover,.post-tag:hover {border-color: #cee0ed !important;}");
  64. //Styles markdown links that we can't write inline CSS for
  65. sb.Append(".has-markdown a,.has-markdown a: visited {color: #0077cc !important;text-decoration: none!important;}");
  66. //Styles markdown code blocks that we can't write inline CSS for
  67. sb.Append("code {padding: 1px 5px;background-color: #eff0f1;color: #242729;font-size: 13px;line-height: inherit;font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono,DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace,sans-serif;}");
  68. sb.Append("pre {margin: 0 0 15px;line-height: 17px;background-color: #eff0f1;padding: 4px 8px;border-radius: 3px;overflow-x: auto;}");
  69. sb.Append("pre code {margin: 0 0 15px;padding: 0;line-height: 17px;background-color: none;}");
  70. //Styles markdown blockquotes that we can't write inline CSS for
  71. sb.Append("blockquote {margin: 0 0 15px;padding: 4px 10px;background-color: #fff8dc;border-left: 2px solid #ffeb8e;}");
  72. sb.Append("blockquote p {padding: 4px 0;margin: 0;overflow-wrap: break-word;}");
  73. //Rounds corners in email clients that support it
  74. sb.Append(".bar {border-radius: 16px;}");
  75. sb.Append(".btr {border-top-left-radius: 16px;border-top-right-radius: 16px;}");
  76. sb.Append(".bbr {border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;}");
  77. sb.Append("@media screen and (max-width: 500px) {");
  78. //Forces table cells into full-width rows
  79. sb.Append(".stack-column,.stack-column-center {display: block!important;width: 100 % !important;max-width: 100 % !important;direction: ltr!important;}");
  80. //And center justify these ones
  81. sb.Append(".stack-column-center {text-align: center !important;}");
  82. //Hides things in small viewports
  83. sb.Append(".hide-on-mobile {display: none!important;max-height: 0 !important;overflow: hidden !important;visibility: hidden !important;}");
  84. //Utility classes to reduce spacing for smaller viewports
  85. sb.Append(".sm-p-none {padding: 0!important;}");
  86. sb.Append(".sm-pt-none {padding-top: 0!important;}");
  87. sb.Append(".sm-pb-none {padding-bottom: 0!important;}");
  88. sb.Append(".sm-pr-none {padding-right: 0!important;}");
  89. sb.Append(".sm-pl-none {padding-left: 0!important;}");
  90. sb.Append(".sm-px-none {padding-left: 0!important;padding-right: 0!important;}");
  91. sb.Append(".sm-py-none {padding-top: 0 !important;padding-bottom: 0!important;}");
  92. sb.Append(".sm-pr {padding-right: 50px !important;}");
  93. sb.Append(".sm-pl {padding-left: 50px !important;}");
  94. sb.Append(".sm-px {padding-left: 50px !important;padding-right: 50px!important;}");
  95. sb.Append(".sm-py {padding-top: 50px !important;padding-bottom: 50px!important;}");
  96. sb.Append("*/ .sm-mb {margin-bottom: 50px !important;}");
  97. //Utility classes to kill border radius for smaller viewports. Used mainly on the email's main container(s)
  98. sb.Append(".bar,.btr,.bbr {border-top-left-radius: 0;border-top-right-radius: 0;border-bottom-left-radius: 0;border-bottom-right-radius: 0;}");
  99. sb.Append("}");
  100. sb.Append("</style>");
  101. sb.Append("</head>");
  102. return sb.ToString();
  103. }
  104. public string MailShowEasyLogo() {
  105. StringBuilder sb = new StringBuilder();
  106. //BODY
  107. //The email background color is defined in three places, just below. If you change one, remember to change the others.
  108. //1. body tag: for most email clients
  109. //2. center tag: for Gmail and Inbox mobile apps and web versions of Gmail, GSuite, Inbox, Yahoo, AOL, Libero, Comcast, freenet, Mail.ru, Orange.fr
  110. //3. mso conditional: For Windows 10 Mail
  111. sb.Append("<body width = \"100%\" style = \"margin: 0;padding: 0!important;background: #f8f8f8;mso-line-height-rule: exactly;\"> ");
  112. sb.Append("<center style=\"width: 100 %; background: #f8f8f8\">");
  113. sb.Append("<div class=\"email-container\" style=\"max-width: 500px; margin: 0 auto\">");
  114. sb.Append("<table border = \"0\" bgcolor = \"#F8F8F8\" cellpadding = \"0\" cellspacing = \"0\" role = \"presentation\" style = \"max-width: 500px; width: 100%\"> ");
  115. //ShowEasy Logo
  116. sb.Append("<tr>");
  117. sb.Append("<td style = \"padding-top: 40px;padding-right:0px;padding-bottom:30px;padding-left:60px; text-align: left\" class=\"sm-px\">");
  118. sb.Append("<a href=\"https://www.showeasy.com/ \">");
  119. sb.Append("<img src = \"https://d3kpqi6h465b7i.cloudfront.net/email/logo.png \" width = \"133\" height = \"18\" style = \"display: block\"/> ");
  120. sb.Append("</a>");
  121. sb.Append("</td>");
  122. sb.Append("</tr>");
  123. return sb.ToString();
  124. }
  125. public string MailButtom() {
  126. StringBuilder sb = new StringBuilder();
  127. //Email Buttom
  128. //Text:If the button isn't working....
  129. sb.Append("<tr>");
  130. sb.Append("<td bgcolor = \"#FEFEFE\" width = \"340\" width = \"340px\" style = \"display: block;padding-top: 30px;padding-left: 30px;padding-right: 30px;color: #9c9c9c;text-align: center;\">");
  131. sb.Append("<p style = \"font-weight: 400;font-size: 12px;line-height: 14px;letter-spacing: 0.02em;font-family: 'arial', 'sans-serif';margin: 0 0 0px;\" class=\"has-markdown\">");
  132. sb.Append("If the button isn't working, you can click the link below:");
  133. sb.Append("</p>");
  134. sb.Append("</td>");
  135. sb.Append("</tr>");
  136. //Link
  137. sb.Append("<tr>");
  138. sb.Append("<td align = \"center\" width = \"340\" bgcolor = \"#FEFEFE\" style = \"display: block;padding-bottom: 30px;padding-top: 0px;padding-left: 30px;padding-right: 30px;color: #9c9c9c;text-align: center;border-bottom-left-radius: 16px;border-bottom-right-radius: 16px;\">");
  139. sb.Append("<a href = \"https://www.showeasy.com/aboutUs \" style = \"color: #7997ff;font-size: 12px;font-weight: 400;font-family: 'Arial', '微軟正黑體','Microsoft JhengHei', 'Helvetica Neue',Helvetica, Arial, sans-serif;padding: 0;margin: 0;text-align: center;padding-left: 0px;padding-right: 30px;padding-top: 4px;text-decoration: underline;\">");
  140. sb.Append("<span align=\"center\" width=\"340\">https://www.showeasy.com/aboutUs</span>");
  141. sb.Append("</a>");
  142. sb.Append("</td>");
  143. sb.Append("</tr>");
  144. sb.Append("</table>");
  145. sb.Append("</td>");
  146. sb.Append("</tr>");
  147. sb.Append("</table>");
  148. sb.Append("</td>");
  149. sb.Append("</tr>");
  150. return sb.ToString();
  151. }
  152. public string MailFooter() {
  153. StringBuilder sb = new StringBuilder();
  154. //Footer
  155. //Text:Follow us
  156. sb.Append("<tr>");
  157. sb.Append("<td style=\"padding-top: 20px; padding-bottom: 20px\" class=\"sm-p\">");
  158. sb.Append("<table align = \"left\" border = \"0\" cellpadding = \"0\" cellspacing = \"0\" role = \"presentation\" width = \"100%\">");
  159. sb.Append("<tr>");
  160. sb.Append("<td style=\"display: block; color: #232323; text-align: left\">");
  161. sb.Append("<h1 style =\"text-align: center;font-family: 'Arial', 'sans-serif';font-weight: 700;font-size: 14px;line-height: 18px;color: #232323;margin: 0 0 0 0;\">");
  162. sb.Append("FOLLOW US");
  163. sb.Append("</h1>");
  164. sb.Append("</td>");
  165. sb.Append("</tr>");
  166. //FB、IG、Medium Icon
  167. sb.Append("<tr>");
  168. sb.Append("<td align=\"center\" style=\"padding-top: 10px\">");
  169. sb.Append("<table>");
  170. sb.Append("<tr align=\"center\">");
  171. sb.Append("<td>");
  172. sb.Append("<img style = \"display: block\" src = \"https://d3kpqi6h465b7i.cloudfront.net/email/icon-facebook.png \" width = \"30\" height = \"30\"/>");
  173. sb.Append("</td>");
  174. sb.Append("<td style=\"padding-left: 20px; padding-right: 20px\">");
  175. sb.Append("<img style =\"display: block\" src = \"https://d3kpqi6h465b7i.cloudfront.net/email/icon-instagram.png \" width = \"30\" height = \"30\"/>");
  176. sb.Append("</td>");
  177. sb.Append("<td>");
  178. sb.Append("<img style = \"display: block\" src = \"https://d3kpqi6h465b7i.cloudfront.net/email/icon-medium.png \" width = \"30\" height = \"30\"/>");
  179. sb.Append("</td>");
  180. sb.Append("</tr>");
  181. sb.Append("</table>");
  182. sb.Append("</td>");
  183. sb.Append("</tr>");
  184. //Text:2022 Showeasy. All rights reserved.
  185. sb.Append("<tr>");
  186. sb.Append("<td style=\"padding-top: 30px\">");
  187. sb.Append("<h1 align = \"center\" style =\"color: #bababa;font-size: 10px;font-weight: 400;font-family: 'Arial', 'sans-serif';padding: 0;margin: 0;line-height: 14px;\">");
  188. sb.Append("© 2023 Showeasy. All rights reserved.");
  189. sb.Append("</h1>");
  190. sb.Append("</td>");
  191. sb.Append("</tr>");
  192. //Text:www.showeasy.com
  193. sb.Append("<tr>");
  194. sb.Append("<td>");
  195. sb.Append("<h1 align = \"center\" style = \"font-weight: 400;color: #232323;line-height: 22px;font-size: 10px;font-weight: 400;font-family: 'Arial', 'sans-serif';padding: 0;margin: 0;\">");
  196. sb.Append("www.showeasy.com");
  197. sb.Append("</h1>");
  198. sb.Append("</td>");
  199. sb.Append("</tr>");
  200. sb.Append("</table>");
  201. sb.Append("</td>");
  202. sb.Append("</tr>");
  203. sb.Append("</table>");
  204. sb.Append("</div>");
  205. sb.Append("</center>");
  206. sb.Append("</body>");
  207. sb.Append("</html>");
  208. return sb.ToString();
  209. }
  210. }
  211. }