javascript - 无法让 Gmail 一键确认操作按钮正常工作

标签 javascript gmail schema.org google-schemas

我遵循此处描述的指南
https://developers.google.com/gmail/schemas/reference/one-click-action

但它只是不会出现在我身上。如上所述here

Self testing

You can easily test if your markup is working correctly end-to-end by sending emails with schemas to your Gmail account. All emails where the sender and the recipient are the same account ignore the registration requirements and can be used for self-testing.

我在发件人和发件人地址中使用相同的 Gmail 地址,如下所示

GradeCard gc = new GradeCard("105106265", "BTS");
var m = new UserMailer().ConfirmSubscription("Shashwat", "user@email.com", new WatchListEmail() { fullName = "from Model", gc = gc });

Response.Write(m.Body);

var client = new SmtpClient("smtp.gmail.com", 587)
{
    Credentials = new NetworkCredential("user@email.com", "xxxxx"),
    EnableSsl = true
};

client.Send(m);

生成邮件的HTML是这样的

<!DOCTYPE html>

<html>
<body>
    <div style="width: 600px; margin: auto; font-family: 'Segoe UI';">
        <h1 style="font-weight:lighter; border-bottom:1px solid #808080; padding:5px 0;">example.com</h1>
        <h3 style="font-weight:lighter;">Action Required. Confirm your subscription for EN abc</h3>
        <p>
            Dear <b>abc</b>
        </p>
        <script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "description": "Action Required. Confirm your subscription for EN 105106265",
  "action": {
    "@type": "ConfirmAction",
    "name": "Add to watchlist",
    "handler": {
      "@type": "HttpActionHandler",
      "url": "http://www.myignou.com?a=1&b=2"
    }
  }
}
</script>

<p>As you requested, We have just added your subscription to the following detailed enrollment number</p>
<p>
    ...
</p>
<p>
    Click <a href="http://www.myignou.com?a=1&b=2">here to confirm</a>
</p>
<div style="margin:10px 0;">
    <p>
        Here is your most recent copy of grade card as on <b>05-09-2013 00:03:37</b><br />
        Changeset ID: xxx
    </p>

    <table style="width: 100%; text-align: center; border-collapse: collapse;">
        ....
    </table>
    <h3 style="font-weight: lighter;">Other previous changes</h3>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:15:20</h4>
            <div>Changeset ID: abc</div>
            <div>
                ...
            </div>
        </div>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:14:21</h4>
            <div>Changeset ID: xxx</div>
            <div>
                ...
            </div>
        </div>
        <div style="padding: 10px">
            <h4 style="font-weight: lighter; margin: 0">Updated on 03-09-2013 15:14:21</h4>
            <div>Changeset ID: abca</div>
            <div>
                ...
            </div>
        </div>
    </div>
        <div style="padding: 10px; margin: 20px 0; background-color: #f2f0f0; font-size: 85%; color: #686868;">
            <b>&copy; 2013 myIGNOU.com</b><br />

        </div>
    </div>
</body>
</html>

最佳答案

您必须首先获得 Google 的批准才能使其发挥作用。

要执行此操作:

  1. 将经过验证的包含架构的电子邮件发送到特殊的 Google 电子邮件地址(使用此工具: https://www.google.com/webmasters/markup-tester/u/0/ )...然后:

  2. 填写“Gmail 架构白名单请求”表单,描述您的网站以及您打算通过一键操作执行的操作。表格如下:https://docs.google.com/forms/d/1PA-vjjk3yJF7MLPOVKbIz3MBfhyma2obS8NIZ0JYx8I/viewform?pli=1&fbzx=-1177483801701354615

关于javascript - 无法让 Gmail 一键确认操作按钮正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18651446/

相关文章:

javascript - 以编程方式关闭/隐藏/删除 Google map 工具提示

javascript - Jquery - 在gmail签名前插入文本

python-3.x - 使用服务帐户和google api python发送邮件

java - 使用服务帐户对 Gmail 进行 OAuth2 身份验证

html - 如何强调无序列表中各个项目的重要性

javascript - 在类中使用 async await 来分配属性但返回 null

javascript - 在 div 内滚动大图像

javascript - 带有内联 block 的奇怪的成长动画

seo - 我可以多次使用 alternateName 吗?

web - JSON-LD Schema.org : Multiple video/image page