【问题标题】:Can't fetch mail body using gmail contextual gadget无法使用 gmail 上下文小工具获取邮件正文
【发布时间】:2013-05-27 07:08:51
【问题描述】:

这是我的 ma​​nifest.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
 
  <Name>My test gadget</Name>
  <Description>Test Gmail contextual gadgets for mail body</Description>
 
 
<Extension id="MailBodyReaderGadget" type="contextExtractor">
  <Name>Mail Body Reader Gadget</Name>
  <Url>google.com:EmailBodyExtractor</Url>
  <Param name="body" value=".*" />  
  <Triggers ref="mailBodyTextWidget" />  
  <Scope ref="emailBody" />
  <Container name="mail" />
</Extension>
 
<!-- our GADGET -->
<Extension id="mailBodyTextWidget" type="gadget">
  <Name>Get mail body</Name>
  <Url>http://test.com/spec.xml</Url>
  <Container name="mail" />
</Extension>
 
<!-- gadget Scope -->
<Scope id="emailBody">
  <Url>tag:google.com,2010:auth/contextual/extractor/BODY</Url>
  <Reason>This app will show the mail body text when you click the button "Show Mail Body"</Reason>
</Scope>

</ApplicationManifest>

spec.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs 
    height="200"
    author=""
    author_email=""
    author_location="US">
        <Require feature="dynamic-height"/>
        <Require feature="google.contentmatch">
            <Param name="extractors">
                google.com:EmailBodyExtractor
            </Param>
        </Require>
    </ModulePrefs>
    <Content type="html" view="card">
    <![CDATA[       
        <script type="text/javascript">
        document.write([
          "\<script src='",
          ("https:" == document.location.protocol) ? "https://" : "http://",
          "ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js' type='text/javascript'>\<\/script>" 
        ].join(''));
        </script>
        <button id="btn">Show Mail Body</button>
        <div id="widget" style="heigth:300px;width:500px;">
        </div>
        <script>
            matches = google.contentmatch.getContentMatches();
            for (var match in matches) {
              for (var key in matches[match]) {                      
                $("#widget").html(matches[match][key]);            
              }
            }        
        </script>     
    ]]>
  </Content>
</Module>

这是我的代码,我已尝试获取邮件主题以及来自和发往电子邮件地址,它已经工作。但主要问题是我无法获取邮件正文。有没有办法解决这个问题?

【问题讨论】:

    标签: google-apps google-gadget


    【解决方案1】:

    答案是删除节点

    这个让我卡住了,因为我认为需要 节点来定义要在我们的小工具中使用的输出参数的名称。

    但实际上MailBodyReaderGadget会自动输出“body”的参数。 所以 节点仅在您希望过滤输出时使用。

    由于你总是想输出body,你可以完全删除这个节点。

    目前无法正常工作的原因是 .* 过滤器不匹配返回字符(将在正文中)

    【讨论】:

      猜你喜欢
      • 2017-04-09
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 2016-04-03
      • 2011-03-18
      • 2015-12-15
      • 2016-12-12
      相关资源
      最近更新 更多