我正在使用 sendgrid Web API 成功发送邮件,但无法将类别添加到 x-smtpapi。这是我的代码:
function getHTML (strUrl,postData)
Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
xmlHttp.Open "POST", strUrl, False
xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
'xmlHttp.AddHeader "category", "web"
xmlHttp.Send postData
getHTML = xmlHttp.responseText
xmlHttp.abort()
set xmlHttp = Nothing
end function
Response.Write("test->" & getHTML("https://sendgrid.com/api/mail.send.json","api_user=myusername&api_key=mykey&to=soneone@somemail.com&subject=test-1 msg&html=this is test message&from=info@zyxxxz.com&category={testweb}"))
Response.End()
但我找不到任何添加类别的方法。
编辑
Response.Write("test->" & getHTML("https://sendgrid.com/api/mail.send.json","api_user=user&api_key=key&to=somemail@somemail.com&subject=test-1 msg&html=this is test message&from=info@xyzzz.com&x-smtpapi={"category":"testCategory"}"))
我需要将其发布为 JSON。如果我不放双引号x-smtpapi={"category":"testCategory"}" JSON解析器无法解析!