Added Schema.org markup to email, won't affect inbox of gmail, neither in mobile app nor web app

Viewed 172

I can send email using C# and System.Net.Mail.SmtpClient and use Gmail as my smtp server. Now I want to add schema markups to my emails. And I expect to see them affect how an email is shown in Google products. I've followed instructions here to do that, but got no success.
I'm using application/ld+json to embed markups.

Here is how I generate the email:

public static Task Main()
{
    var mail = new MailMessage("mygmail@gmail.com", "mygmail@gmail.com");

    var client = new SmtpClient("smtp.gmail.com", 587);
    client.EnableSsl = true;
    client.Credentials = new System.Net.NetworkCredential("mygmail@gmail.com", "my password");

    mail.Subject = "fight confirmation";
    mail.IsBodyHtml = true;
    mail.Body = GetMailBody (); 
    await client.SendMailAsync (mail);
}

Here is the my GetMailBody() method:

public static string GetMailBody ()
{
    return @"
<html>
<body>
<script type=""application/ld+json"">
{
  ""@context"": ""http://schema.org"",
  ""@type"": ""EmailMessage"",
  ""potentialAction"": {
     ""@type"": ""ConfirmAction"",
    ""name"": ""Approve Expense"",
    ""handler"": {
      ""@type"": ""HttpActionHandler"",
      ""url"": ""https://myexpenses.com/approve?expenseId=abc123""
    }
  },
  ""description"": ""Approval request for John's $10.13 expense for office supplies""
}
</script>
Let me know if you're in.
</body>
</html>

        ";
}

I expect to see a button in inbox, like the one shown in Google documentations: enter image description here

But everything in my inbox is the same as it is without any schema markup.

1 Answers

I have spend few hours testing your schema and code.

To start with in general there is no issue in your codes, but the main reason that these button does not show is as I understood from different resources that this require your own email to be signed with DKIM or SPF in order fro Gmail to render the action.

Check this answer, this answer and this answer both have the same issue and mentioning the same solution.

In addition when you reach with your email whitelisting, I will leave some tools and resources links that will help you validating your schema data and move on with it:

Finally, this might be irrelevant to your question but good to mentions, is that these action button are only rendered for Gmail owners, not other email clients, that means also if you are looking for more generic way to show a button in your email, maybe just regular html will do the trick, here is a quick example:

public static string GetMailBody()
{
    return @"
    <table width=""100%"" cellspacing=""0"" cellpadding=""0"">
      <tr>
        <td>Approval request for John's $10.13 expense for office supplies</td>
      </tr>
      <tr>
          <td>
              <table cellspacing=""0"" cellpadding=""0"">
                  <tr>
                      <td style=""border-radius: 2px;"" bgcolor=""#ED2939"">
                          <a href=""https://www.yourWebConfirmationLink.com"" target=""_blank"" style=""padding: 8px 12px; border: 1px solid #ED2939;border-radius: 2px;font-family: Helvetica, Arial, sans-serif;font-size: 14px; color: #ffffff;text-decoration: none;font-weight:bold;display: inline-block;"">
                              Confirm Your Order             
                          </a>
                      </td>
                  </tr>
              </table>
          </td>
      </tr>
    </table>
";
}

this will give:

enter image description here

Related