1

在 iOS 上使用 MFMailComposeViewController 时,是否可以在 html 模板中添加 gmail 操作按钮?我正在尝试通过向自己发送电子邮件来进行测试,但到目前为止,从 iOS 向自己发送电子邮件时,我无法让操作按钮显示在 gmail 中?

我正在使用保存为 Test.html 的示例 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>

并像这样发送该电子邮件:

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];

这会弹出我手机上的默认邮件应用程序,然后我将电子邮件发送到我的 gmail 帐户。我收到了电子邮件,但在浏览器中查看电子邮件时没有操作按钮(不是在 iOS 上)。我猜它不起作用,因为电子邮件没有正确签名?

编辑。这是电子邮件来源:

    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--
4

1 回答 1

1

缺少签名很可能是按钮未显示的原因。

请将电子邮件来源添加到您的问题中,以便我们确认。您可以通过打开下拉菜单并选择“显示原件”从 Gmail 中获取它。

于 2013-07-18T08:45:27.623 回答