Question

Is it possible to add a gmail action button within an html template when using MFMailComposeViewController on iOS? I'm trying to test by sending emails to myself, but so far I can't get the action button to show up in gmail when sending an email to myself from iOS?

I'm using this sample HTML code saved as Test.html:

<html>
  <head>
    <script type="application/ld+json">
    {
      "@context":       "http://schema.org",
      "@type":          "EmailMessage",
      "description":    "Check this out",
      "action": {
        "@type": "ViewAction",
        "url":   "https://www.youtube.com/watch?v=eH8KwfdkSqU"
      }
    }
    </script>
  </head>
  <body>
    <p>
      This a test for a Go-To action in Gmail.
    </p>
  </body>
</html>

And sending that email like this:

MFMailComposeViewController *emailController = [[MFMailComposeViewController alloc] init];
    [emailController setSubject:@"This is a test"];
    NSString *emailFileName = [NSString stringWithFormat:@"Test.html"];
    NSString *emailFilePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:emailFileName];
    NSString *body = [NSString stringWithContentsOfFile:emailFilePath encoding:NSUTF8StringEncoding error:nil];
    [emailController setMessageBody:body isHTML:YES];

This pops open the default Mail app on my phone and I send the email to my gmail account. I receive the email but no action button is present when viewing the email in the browser (not on iOS). I'm guessing it's not working because the email isn't signed properly?

Edit. Here's the email source:

    Return-Path: <erik.maxwell.hunter@gmail.com>
Received: from [10.228.122.48] (mobile-198-228-192-015.mycingular.net. [198.228.192.15])
        by mx.google.com with ESMTPSA id t10sm1451398igz.9.2013.07.16.06.49.19
        for <erik.maxwell.hunter@gmail.com>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 16 Jul 2013 06:49:20 -0700 (PDT)
Content-Type: multipart/alternative; boundary=Apple-Mail-FF6A80E5-6EEB-48DC-AA50-D59C49D21235
Content-Transfer-Encoding: 7bit
Subject: Hey, I shared a photo with you!
From: Personal Gmail <erik.maxwell.hunter@gmail.com>
Message-Id: <3C165C2C-C0F9-444B-85C1-84E96750CA1D@gmail.com>
Date: Tue, 16 Jul 2013 09:49:16 -0400
To: Erik Hunter <erik.maxwell.hunter@gmail.com>
Mime-Version: 1.0 (1.0)
X-Mailer: iPhone Mail (10A403)


--Apple-Mail-FF6A80E5-6EEB-48DC-AA50-D59C49D21235
Content-Type: text/plain;
    charset=us-ascii
Content-Transfer-Encoding: 7bit

This a test for a Go-To action in Gmail.    
--Apple-Mail-FF6A80E5-6EEB-48DC-AA50-D59C49D21235
Content-Type: text/html;
    charset=utf-8
Content-Transfer-Encoding: 7bit

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>

    <script type="application/ld+json">
    {
      "@context":       "http://schema.org",
      "@type":          "EmailMessage",
      "description":    "Check this out",
      "action": {
        "@type": "ViewAction",
        "url":   "https://www.youtube.com/watch?v=eH8KwfdkSqU"
      }
    }
    </script>


    <p>
      This a test for a Go-To action in Gmail.
    </p>

</div></body></html>
--Apple-Mail-FF6A80E5-6EEB-48DC-AA50-D59C49D21235--
Was it helpful?

Solution

The lack of signature is quite likely the reason why the button is not showing.

Please add the email source to your question so that we can confirm. You can get it from Gmail by opening the drop-down menu and selecting "Show original".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top