<tfoot id='BXn7c'></tfoot>

    <small id='BXn7c'></small><noframes id='BXn7c'>

    <i id='BXn7c'><tr id='BXn7c'><dt id='BXn7c'><q id='BXn7c'><span id='BXn7c'><b id='BXn7c'><form id='BXn7c'><ins id='BXn7c'></ins><ul id='BXn7c'></ul><sub id='BXn7c'></sub></form><legend id='BXn7c'></legend><bdo id='BXn7c'><pre id='BXn7c'><center id='BXn7c'></center></pre></bdo></b><th id='BXn7c'></th></span></q></dt></tr></i><div id='BXn7c'><tfoot id='BXn7c'></tfoot><dl id='BXn7c'><fieldset id='BXn7c'></fieldset></dl></div>
      <legend id='BXn7c'><style id='BXn7c'><dir id='BXn7c'><q id='BXn7c'></q></dir></style></legend>
        <bdo id='BXn7c'></bdo><ul id='BXn7c'></ul>

    1. Google Apps 脚本 - 将 gmail 中的数据提取到电子表格中

      Google Apps Scripts - Extract data from gmail into a spreadsheet(Google Apps 脚本 - 将 gmail 中的数据提取到电子表格中)

      1. <i id='Ck9Yr'><tr id='Ck9Yr'><dt id='Ck9Yr'><q id='Ck9Yr'><span id='Ck9Yr'><b id='Ck9Yr'><form id='Ck9Yr'><ins id='Ck9Yr'></ins><ul id='Ck9Yr'></ul><sub id='Ck9Yr'></sub></form><legend id='Ck9Yr'></legend><bdo id='Ck9Yr'><pre id='Ck9Yr'><center id='Ck9Yr'></center></pre></bdo></b><th id='Ck9Yr'></th></span></q></dt></tr></i><div id='Ck9Yr'><tfoot id='Ck9Yr'></tfoot><dl id='Ck9Yr'><fieldset id='Ck9Yr'></fieldset></dl></div>

      2. <tfoot id='Ck9Yr'></tfoot>

            • <bdo id='Ck9Yr'></bdo><ul id='Ck9Yr'></ul>
              • <legend id='Ck9Yr'><style id='Ck9Yr'><dir id='Ck9Yr'><q id='Ck9Yr'></q></dir></style></legend>

                  <tbody id='Ck9Yr'></tbody>

                <small id='Ck9Yr'></small><noframes id='Ck9Yr'>

                本文介绍了Google Apps 脚本 - 将 gmail 中的数据提取到电子表格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我尝试从头开始编写的第一个脚本.到现在为止都不好,所以我要寻求一些帮助.

                this is the first script i try to write from scratch. It's been no good up to now so i'm going to ask for some help.

                案例:我收到来自电子商务网站的电子商务确认电子邮件,没有回复电子邮件地址.在电子邮件的正文中,他们发送买家的电子邮件地址.我想向正文的电子邮件地址发送一封自动邮件.

                Case: I recieve e-commerce confirmation emails from e-commerce sites no reply email address. In the email's body they send email address from buyers. I want to send an automated mail to the body's email address.

                我打算如何做到这一点(感谢任何消除步骤的建议).

                How i plan to do this (any suggetions to eliminate steps will be thanked).

                1. 使用规则为收到的电子邮件添加唯一标签.

                1. Use a rule to tag incoming emails with a unique tag.

                使用该标签通过脚本识别 gmail 中的电子邮件,逐一提取我需要的信息.使用带有电子邮件正文内容的正则表达式来提取我需要发送自动电子邮件的电子邮件地址.计划是从正文获取:主题、日期、电子邮件.

                Use that tag to identify emails in gmail with a script, go one by one and extract the info i need. Use regex with the emails body content to extract the email address i need to send the automated emails. Plan is to get: subject, date, email from body.

                将所有信息写入电子表格.

                Write all that info to a spreadsheet.

                去掉唯一的标签信息以防止重复运行.

                Get rid of unique tag info to prevent duplicate runs.

                然后使用 form mule 插件从电子表格发送电子邮件.

                Then use form mule addon to send emails from the spreadsheet.

                到目前为止,我已经处理了第 1 步(简单),并且一直在为第 2 步和第 3 步而苦恼(我不是编码员,我可以阅读、解散和破解.从头开始写作是完全不同的事情).在我认为这是处理它的最佳方法之前,我已经处理了 4 个.

                So far, i've dealt with steps 1 (easy), and been stuggling with steps 2 and 3 (im not a coder, i can read, undestrand and hack. writing from scratch is a completely different thing). Ive dealt with 4 before i think this is the best way to deal with it.

                通过脚本我将信息提取到电子表格中,通过插件我使用电子表格中的信息发送电子邮件.

                With the script i extract info to the spreadsheet, with the addon i use the info from the spreadsheet to send emails.

                这是我到目前为止编写的代码.我把正则表达式部分留到以后,因为我什至还不能在电子表格中写任何东西.一旦我开始工作,我就开始使用正则表达式和脚本的删除标签"方面.

                This is the code ive written so far. I've left the regex part for later cause i cant even write anything into the spreadsheet yet. once i get that working, ill start working in the regex and "remove the label" aspects of the script.

                function myFunction() {
                  function getemails() {
                    var label = GmailApp.getUserLabelByName("Main tag/subtag");
                    var threads = label.getThreads();
                    for (var i = 0; i < threads.length; i++) { 
                    var messages=threads[i].getMessages();  
                      for (var j = 0; j < messages.length; j++) {
                    var message=messages[j];
                    var subject=message.getSubject();
                    tosp(message);
                      }
                     }
                  }
                
                  function tosp(message){
                    var body=message.getBody()
                    var date=message.getDate();
                    var subject=message.getSubject(); 
                    var id= "my spreasheet id";
                    var ss = SpreadsheetApp.openById(id);
                    var sheet = ss.getActiveSheet();
                    sheet.appendRow(subject,date,body);    
                
                }
                } 
                

                任何帮助将不胜感激.

                谢谢塞巴斯蒂安

                推荐答案

                以下是我编写和测试的代码,它完美地执行了您提到的步骤 2、3 和 4.

                Following is the code I wrote and tested that performs the steps 2, 3 and 4 mentioned by you perfectly well.

                function myFunction() {
                
                  var ss = SpreadsheetApp.getActiveSheet();
                
                  var label = GmailApp.getUserLabelByName("MyLabel");
                  var threads = label.getThreads();
                
                  for (var i=0; i<threads.length; i++)
                  {
                    var messages = threads[i].getMessages();
                
                    for (var j=0; j<messages.length; j++)
                    {
                      var msg = messages[j].getBody();
                      var sub = messages[j].getSubject();
                      var dat = messages[j].getDate();
                
                      ss.appendRow([msg, sub, dat])
                    }
                      threads[i].removeLabel(label);
                  }
                }
                

                您的代码中的一个错误是 appendRow 函数接受在 [ ] 括号内指定的元素数组.

                One of the faults in your code was that the appendRow function accepts an array of elements specified within [ ] brackets.

                根据您附加此脚本的位置,您的代码行:

                Depending on where you're attaching this script, your line of code:

                var ss = SpreadsheetApp.openById(id);
                

                如果脚本是在您希望记录这些电子邮件的电子表格的脚本编辑器中编写的,则不需要.但是,如果该电子表格中有多个工作表,您可以替换我的行

                is not necessary if the script is being written in the script editor of the Spreadsheet where you want these emails to be logged. However, if there are multiple sheets in that spreadsheet, you can replace my line

                var ss = SpreadsheetApp.getActiveSheet();
                

                通过

                var ss = SpreadsheetApp.getActiveSpreadsheet();
                var sheet = ss.getSheetByName("Sheet1");
                

                另一个建议是当前代码将以 HTML 格式为您提供消息.因此,如果您想以纯文本形式获取消息,请使用:

                Another suggestion is that the current code will give you messages in HTML format. Hence, if you want to get the message in plain text as you see it, use:

                var msg = messages[i].getPlainBody();
                

                现在您可以为正则表达式编写另一个函数并将消息 msg 传递给该函数.希望这会有所帮助!

                Now you can write another function for regex and pass the message msg to that. Hope this helps!

                这篇关于Google Apps 脚本 - 将 gmail 中的数据提取到电子表格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Gradient Button to background-color blinks on hover(悬停时背景颜色的渐变按钮闪烁)
                How to make hovering over active button not use hover effect?(如何使悬停在活动按钮上不使用悬停效果?)
                html javascript show image hover(html javascript 显示图像悬停)
                How to get css hover values on click?(如何在点击时获得 css 悬停值?)
                Change background image on link hover(更改链接悬停时的背景图像)
                Highlight multiple items on hover#39;s condition(突出显示悬停条件下的多个项目)
                    <bdo id='2NSXC'></bdo><ul id='2NSXC'></ul>
                      <tbody id='2NSXC'></tbody>
                  • <legend id='2NSXC'><style id='2NSXC'><dir id='2NSXC'><q id='2NSXC'></q></dir></style></legend>

                          <small id='2NSXC'></small><noframes id='2NSXC'>

                          <tfoot id='2NSXC'></tfoot>
                        • <i id='2NSXC'><tr id='2NSXC'><dt id='2NSXC'><q id='2NSXC'><span id='2NSXC'><b id='2NSXC'><form id='2NSXC'><ins id='2NSXC'></ins><ul id='2NSXC'></ul><sub id='2NSXC'></sub></form><legend id='2NSXC'></legend><bdo id='2NSXC'><pre id='2NSXC'><center id='2NSXC'></center></pre></bdo></b><th id='2NSXC'></th></span></q></dt></tr></i><div id='2NSXC'><tfoot id='2NSXC'></tfoot><dl id='2NSXC'><fieldset id='2NSXC'></fieldset></dl></div>