MCPcopy Create free account
hub / github.com/AS-AIGC/TranscriptHub / SendEmailNotify

Function SendEmailNotify

apps/frontend/sendmail.go:17–82  ·  view source on GitHub ↗

0) Error 1)Canceled 10)job done 請自行修改信件內容

(taskID string, state int)

Source from the content-addressed store, hash-verified

15// 0) Error 1)Canceled 10)job done
16// 請自行修改信件內容
17func SendEmailNotify(taskID string, state int) {
18 job, err := ReadJobsViaTaskID(taskID)
19 if err != nil {
20 fmt.Println(err.Error())
21 return
22 }
23 status := "執行完成"
24 if state == 0 {
25 status = "因錯誤中斷"
26 } else if state == 1 {
27 status = "因故被取消執行"
28 }
29
30 app, err := MailService.NewSMTPMail()
31 if err != nil {
32 fmt.Println("Send email notify error:" + err.Error())
33 return
34 }
35
36 subject := "【ITS】AI Suite 系統通知"
37 body := fmt.Sprintf(`
38 <!DOCTYPE html>
39 <html>
40 <body>
41 <p>敬啟者,<br /><br />感謝您使用中央研究院 AI 錄音轉逐字稿服務。您於 %s 上傳的檔案 %s 已於%s %s。請點擊以下連結進入系統查詢您的逐字稿內
42容。<br><br>提醒您,轉檔文件僅保留 30 天,請盡速保存資料。<br><br><br>查詢逐字稿連結:<br>https://....its.sinica.edu.tw<br><br>使用意見回饋表
43單:<a href="https://forms.gle/...">請點擊此處填寫表單</a><br><br>
44 資訊服務處 敬啟
45 </p>
46 <p>
47線上服務台 (上班時間):https://its.sinica.edu.tw/online<br>
48電話(上班時間):02-27898855<br>
49信箱:its@sinica.edu.tw
50 </p>
51 <p>Dear User,<br><br>
52 Thank you for using Academia Sinica’s AI Audio-to-Text Service. The file %s that you uploaded on %s has been successfully processed at %s. Please click the link below to access your transcript.<br>
53Kindly note that the transcribed file will only be retained for 30 days, so please save your data promptly.<br><br><br>
54 Transcript Access Link:<br> https://aisuite.its.sinica.edu.tw
55 Feedback Form: [<a href="https://forms.gle/...">Click here to fill out the form</a>]<br><br>
56 Department of Information Technology Services<br>
57 Online Helpdesk (Office Hours): https://its.sinica.edu.tw/online<br>
58 Tel (Office Hours): +886-2-2789-8855<br>
59 E-mail: its@sinica.edu.tw
60 </body>
61 </html>
62 `, job.UploadTime, job.FileName, job.FinishTime, status, job.FileName, job.UploadTime, job.FinishTime)
63
64
65 // 完整的 MIME 訊息
66 var msg bytes.Buffer
67 msg.WriteString(fmt.Sprintf("From: 資訊處 <%s>\r\n", mime.QEncoding.Encode("utf-8", app.From)))
68 msg.WriteString(fmt.Sprintf("To: %s\r\n", job.Owner))
69 msg.WriteString(fmt.Sprintf("Subject: %s\r\n", mime.QEncoding.Encode("utf-8", subject)))
70 msg.WriteString("MIME-Version: 1.0\r\n")
71 msg.WriteString("Content-Type: text/html; charset=UTF-8\r\n")
72 msg.WriteString("\r\n")
73 msg.WriteString(fmt.Sprintf("--\r\n"))
74 msg.WriteString(body)

Callers 2

UpdateJobsViaTaskIDFunction · 0.85
SendTestEmailFromWebFunction · 0.85

Calls 1

ReadJobsViaTaskIDFunction · 0.85

Tested by

no test coverage detected