html - 将文本和表格添加到 Outlook 正文
问题描述
我想在 Go 中通过 Gomail 在 Outlook 正文中发送 3 行文本和一个表格。该表是从结构数组创建的。
我就是这样把身体送进去的。
m.SetBody("text/html", body)
参考这个链接,Show a table from a slice with my struct Golang,我试图创建一个 html 格式的表格。但它会创建一个 html 文件。
var basenameOpts = []Test {
Test {
Entity: "a",
SourceSystem: "multiple",
Customer : "Usage for a",
},
Test{
Entity: "test",
SourceSystem: "b-option",
Customer : "Usage for b",
},
}
type PageData struct {
Title string
Data []Test
}
func MyStructHandler(w http.ResponseWriter, r *http.Request) {
data := PageData{
Text: "My Super Awesome Page of Structs./n/n New line./n/n Next line",
Data: basenameOpts,
}
t := template.Must(template.ParseFiles("./showmystruct.html"))
t.Execute(w, data)
}
我应该如何将 html 格式的正文转换为字符串以将其传递给 m.SetBody?
解决方案
推荐阅读
- websphere - IBM WebSphere Application Server (V9) 如何处理 HTTP 基本认证中的领域
- reactjs - 映射表记录时,如何在 React 中单击按钮时使一个表记录可编辑?
- php - 如何从 php apache 服务器向 ios 设备发送推送通知?
- javascript - 如何从我的 vuex 操作中分离 Firestore 侦听器?
- jquery - Ruby on Rails - 由于 Ajax 提交了两次表单
- mongodb - mongodb find.count({}) 显示的数据少于 find({
}) - macos - 为什么当我尝试使用 grep ether 过滤 ifconfig 结果以仅显示媒体显示的 MAC 地址时?
- selenium - Selenium:等到属性值改变
- python - 如何根据用户输入自动添加唯一键,然后在python中更新它
- c# - FromBody 收到的帖子导致可序列化错误