email.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. package services
  2. import (
  3. "eta/eta_api/models"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. "strings"
  7. )
  8. func SendEmailToCompany() {
  9. // 获取收件人列表
  10. //emailCond := " AND enabled = 1 "
  11. emailCond := ""
  12. emailPars := make([]interface{}, 0)
  13. emails, e := models.GetEnglishReportEmailList(emailCond, emailPars, "")
  14. if e != nil {
  15. fmt.Println("获取收件人列表失败, Err: " + e.Error())
  16. return
  17. }
  18. if len(emails) == 0 {
  19. fmt.Println("收件人列表为空")
  20. return
  21. }
  22. // TODO:这是HTML模板内容
  23. template := `<!DOCTYPE html>
  24. <html lang="en">
  25. <head>
  26. <meta charset="UTF-8">
  27. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  28. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,viewport-fit=cover">
  29. <title>Horizon Insights x Fastmarkets x FGE: 2024 Macro & Commodities Outlook - Registration Open!</title>
  30. </head>
  31. <body style="padding:0;margin:0;background-color:#fff">
  32. <div id="app" style="max-width:1280px;margin:0 auto;font-size:14px;min-height:100vh;">
  33. <div class="main-box" style="padding:25px 20px;">
  34. <div style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"
  35. class=" __aliyun_node_has_color">
  36. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:center;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  37. class=" __aliyun_node_has_color"><span
  38. style="font-size:18.0px;font-weight:bold;font-style:normal;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;color:#000000;text-decoration:underline;"
  39. class=" __aliyun_node_has_color">2024 Macro &amp; Commodities Outlook Invite</span></div>
  40. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  41. class=" __aliyun_node_has_color"><span
  42. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;"
  43. class=" __aliyun_node_has_color"><br></span></div>
  44. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  45. class=" __aliyun_node_has_color"><span
  46. style="font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;"
  47. class=" __aliyun_node_has_color">Dear Client,</span></div>
  48. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  49. class=" __aliyun_node_has_color"><span
  50. style="font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;"
  51. class=" __aliyun_node_has_color"><br></span></div>
  52. <div style="clear:both;">
  53. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  54. class=" __aliyun_node_has_color"></div>
  55. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  56. class=" __aliyun_node_has_color"></div>
  57. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  58. class=" __aliyun_node_has_color"><span
  59. style="font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;"
  60. class=" __aliyun_node_has_color">Happy Year-End Holidays!</span></div>
  61. </div>
  62. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  63. class=" __aliyun_node_has_color"><span
  64. style="font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;"
  65. class=" __aliyun_node_has_color"><br></span></div>
  66. <div style="clear:both;">
  67. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  68. class=" __aliyun_node_has_color"></div>
  69. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  70. class=" __aliyun_node_has_color"></div>
  71. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  72. class=" __aliyun_node_has_color"><span
  73. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;border:.0px;font-family:arial;margin:.0px;padding:.0px;outline:.0px;font-size:13.0px;"
  74. class=" __aliyun_node_has_color">As we usher in the new year, Horizon Insights, in collaboration
  75. with Fastmarkets and FGE, is proud to announce</span><span
  76. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;font-family:arial;font-size:13.0px;"
  77. class=" __aliyun_node_has_color">&nbsp;our 2024 Macro &amp; Commodities Outlook which will be
  78. held&nbsp;</span><span
  79. style="font-weight:bold;color:#000000;font-style:normal;text-transform:none;font-family:arial;font-size:13.0px;text-decoration:none;"
  80. class=" __aliyun_node_has_color">virtually</span><span
  81. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;font-family:arial;font-size:13.0px;text-decoration:none;"
  82. class=" __aliyun_node_has_color">&nbsp;on&nbsp;</span><span
  83. style="font-weight:bold;color:#000000;font-style:normal;text-transform:none;font-family:arial;font-size:13.0px;text-decoration:none;"
  84. class=" __aliyun_node_has_color">10 &amp; 11 Jan 2024</span><span
  85. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;font-family:arial;font-size:13.0px;"
  86. class=" __aliyun_node_has_color">,&nbsp;</span><span
  87. style="color:#000000;font-family:arial;font-size:13.0px;font-style:normal;font-weight:bold;text-transform:none;"
  88. class=" __aliyun_node_has_color">5pm - 8pm SGT</span><span
  89. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;font-family:arial;font-size:13.0px;"
  90. class=" __aliyun_node_has_color">&nbsp;(i.e.&nbsp;</span><span
  91. style="color:#000000;font-family:arial;font-size:13.0px;font-style:normal;font-weight:bold;text-transform:none;"
  92. class=" __aliyun_node_has_color">9am - 12pm BST</span><span
  93. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;font-family:arial;font-size:13.0px;"
  94. class=" __aliyun_node_has_color">). Our experienced analysts from Horizon Insights together with
  95. guest speakers from our valued partners will present our views in the fields of Macro, Ferrous
  96. Metals, Base Metals, Energy, as well as Petrochemicals.</span></div>
  97. </div>
  98. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  99. class=" __aliyun_node_has_color"><span
  100. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-size:13.0px;font-family:arial;"><br></span>
  101. </div>
  102. <div style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;"
  103. class=" __aliyun_node_has_color"><span
  104. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-size:13.0px;font-family:arial;">Please
  105. see below for our event schedule:</span></div>
  106. <div
  107. style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;">
  108. <br></div>
  109. <div
  110. style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;">
  111. <span
  112. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-size:13.0px;font-family:arial;"
  113. class=" __aliyun_node_has_color">&nbsp;&nbsp;<img style="vertical-align: bottom; margin: 0px;"
  114. height="3301"
  115. src="https://hzstatic.hzinsights.com/static/images/202312/20231228/KeDTAxIZ3UrZR5DZKKIQLdoIaOVB.png"
  116. width="890"></span></div>
  117. <div
  118. style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;">
  119. <span
  120. style="color:#000000;font-style:normal;font-weight:400;text-transform:none;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-size:13.0px;font-family:arial;"
  121. class=" __aliyun_node_has_color">&nbsp; &nbsp;</span></div>
  122. <div
  123. style="clear:both;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;text-indent:.0px;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;">
  124. <br></div>
  125. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  126. class=" __aliyun_node_has_color"><span
  127. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;"><br></span>
  128. </div>
  129. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  130. class=" __aliyun_node_has_color"><span
  131. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;">To
  132. register, simply scan the QR code in the posters above to indicate your interest. Alternatively, you
  133. may also&nbsp;</span><span
  134. style="font-weight:bold;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;"><a
  135. href="https://forms.gle/yhPRDcri43P2QyPt8" target="_blank">register here</a></span><span
  136. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;">.</span>
  137. </div>
  138. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  139. class=" __aliyun_node_has_color"><span
  140. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;color:#000000;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"
  141. class=" __aliyun_node_has_color">Should you encounter any difficulties registering, please contact
  142. Stephanie (stephanie@hzinsights.com).</span></div>
  143. <div>
  144. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  145. class=" __aliyun_node_has_color"></div>
  146. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  147. class=" __aliyun_node_has_color"><span
  148. style="font-weight:bold;margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;">The
  149. virtual meeting details will be disseminated to you a few days prior to the event.</span></div>
  150. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  151. class=" __aliyun_node_has_color"><br></div>
  152. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  153. class=" __aliyun_node_has_color"><span
  154. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;">Lastly,
  155. our firm would like to wish all of you a prosperous Happy New Year! We look forward to seeing
  156. everyone on the 10th &amp; 11th.</span></div>
  157. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  158. class=" __aliyun_node_has_color"><span
  159. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;"><br></span>
  160. </div>
  161. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;text-align:start;text-indent:.0px;text-transform:none;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;clear:both;"
  162. class=" __aliyun_node_has_color"><span
  163. style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:arial;font-size:13.0px;">Cheers!</span>
  164. </div>
  165. </div>
  166. <div><br></div>
  167. <div>
  168. <div style="clear:both;"><span style="font-family:arial;font-size:13.0px;color:#000000;"
  169. class=" __aliyun_node_has_color"><br></span></div>
  170. <div style="clear:both;">
  171. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;clear:both;font-variant-caps:normal;text-align:start;text-indent:.0px;"
  172. class="x___aliyun_node_has_color"><br></div>
  173. <div style="margin:.0px;padding:.0px;border:.0px;outline:.0px;clear:both;font-variant-caps:normal;text-align:start;text-indent:.0px;"
  174. class="x___aliyun_node_has_color"></div>
  175. </div>
  176. </div>
  177. <div><br></div>
  178. <div><br></div>
  179. <div><br></div>
  180. <div style="line-height:20.0px;clear:both;"><br></div>
  181. </div>
  182. </div>
  183. </div>
  184. </body>
  185. </html>`
  186. // 推送信息
  187. sendData := make([]*EnglishReportSendEmailRequest, 0)
  188. for i := range emails {
  189. r := new(EnglishReportSendEmailRequest)
  190. r.EmailId = emails[i].Id
  191. r.Email = strings.Replace(emails[i].Email, " ", "", -1)
  192. r.Subject = "Horizon Insights x Fastmarkets x FGE: 2024 Macro & Commodities Outlook - Registration Open!" // TODO:这是主题
  193. r.FromAlias = "Horizon FICC" // TODO:这是推送人(中文)
  194. r.HtmlBody = template
  195. sendData = append(sendData, r)
  196. }
  197. if len(sendData) == 0 {
  198. fmt.Println("无邮件可推送")
  199. return
  200. }
  201. // 请求阿里云接口批量推送
  202. aliEmail := new(AliyunEmail)
  203. resultList, e := aliEmail.BatchSendEmail(sendData)
  204. if e != nil {
  205. fmt.Println("批量推送失败, Err: " + e.Error())
  206. return
  207. }
  208. for _, r := range resultList {
  209. utils.FileLog.Info("email: %s, ok: %v, res: %s", r.Email, r.Ok, r.ResultData)
  210. if r.Ok {
  211. fmt.Println("发送成功")
  212. } else {
  213. fmt.Println("发送失败:" + r.ResultData)
  214. }
  215. }
  216. }