[英]Gmail: Sync Inbox (IMAP & POP3 disabled)
There is a need to read my sent items from my gmail account between two dates and that follows a similar text pattern on the subject, this is all in order to segregate the sent items that has been answered (stored in a excel file) and re-send one reminder to those that hasn't answered. 有必要在两个日期之间从我的gmail帐户中读取我的已发送邮件,并且在主题上遵循类似的文本模式,所有这些都是为了隔离已答复的已发送邮件(存储在excel文件中)并重新-向未回答的人发送提醒。
The problem described above seems to be easy to handle and a good task to perform with the usage of a scripting language, except for the statement below: 上面描述的问题似乎很容易处理,并且使用脚本语言可以很好地完成任务,以下语句除外:
So, the IT folks of the place that I work decided to disable IMAP & POP3 from every single account of the company. 因此,我工作地点的IT人员决定从公司的每个帐户中禁用IMAP和POP3。 Believe it or not this is for a good reason, In order to avoid the usage of an email client (in this case MS Outlook) and save some money --- I've always believed in open source ---. 信不信由你,这是有充分的理由的,为了避免使用电子邮件客户端(在本例中为MS Outlook)并节省一些钱--- 我一直相信开源 ---。
Then, I was wondering on How would it be possible to syncronize the inbox of my gmail account knowing that the company that I work had disabled both IMAP & POP3. 然后,我想知道如何才能同步我的gmail帐户的收件箱,因为我工作的公司同时禁用了IMAP和POP3。
As far as I know SMTP is only for sending email but not for retrieving them. 据我所知,SMTP仅用于发送电子邮件,而不用于检索电子邮件。
Being a little bit stubborn and blinded by the idea of avoiding the usage of Sockets in order to accomplish this ridiculous task, I've ended up playing with the following ruby gems: 为避免完成此荒谬的任务而避免使用Sockets的想法使我有些固执和蒙蔽,我最终使用了以下宝石红宝石:
Above two gems are awesome for sending/retrieving emails, but only if your account have IMAP or POP3 enabled. 以上两个gem非常适合发送/检索电子邮件,但前提是您的帐户启用了IMAP或POP3。
How come that my devices can syncronize my inbox even if IMAP & POP3 are disabled. 即使禁用了IMAP和POP3,我的设备如何能够同步收件箱。
Without IMAP you're really left with no options. 没有IMAP,您将无可奈何。 I don't see a way to do it without making some kind of screen scraping bot, and then parsing that information is going to be a huge mess. 如果没有制作某种屏幕抓取机器人,然后解析该信息将是一团糟,我看不出有办法做到这一点。 Is there a reason you can't use the label and filter system built into Gmail to make a label with the emails you're after? 您是否有理由无法使用Gmail内置的标签和过滤器系统来为收到的电子邮件添加标签?
In order to avoid the usage of sockets for this assignment I've tried to build an Chrome extension/apps, but this would become as riduculous as using sockets. 为了避免在此任务中使用套接字,我尝试构建一个Chrome扩展程序/应用程序,但这会变得与使用套接字一样繁琐。
Thanks god Google Apps Script exists. 谢谢上帝Google Apps脚本的存在。
var VENDOR_NAME_INDEX = 0;
var CONTACTS_INDEX = VENDOR_NAME_INDEX + 1;
var HAS_REPLIED_INDEX = CONTACTS_INDEX + 1;
var COMMENTS_INDEX = HAS_REPLIED_INDEX + 1;
var VENDORS_SPREADSHEET_URL = "https://docs.google.com/a/jabil.com/spreadsheet/ccc?key=0Aj7MWNXx-gzsdHJQbGhQZUVkMjBFeVNZX0dXdDZjYWc#gid=0";
var VENDORS_GMAIL_QUERY = 'in:sent has:attachment after:2013/06/26 before:2013/06/28 subject: "*Jabil CUU /// Shipping Letter*"';
// http://flesler.blogspot.mx/2008/11/fast-trim-function-for-javascript.html
String.prototype.trimLeft = function() {
var pivot = -1;
while (this.charCodeAt(++pivot) < 33);
return this.slice(pivot, this.length);
}
// http://flesler.blogspot.mx/2008/11/fast-trim-function-for-javascript.html
String.prototype.trimRight = function() {
var pivot = this.length;
while (this.charCodeAt(pivot--) < 33);
return this.slice(0, pivot);
}
vendors = [];
function processSentItems() {
var threads = GmailApp.search(VENDORS_GMAIL_QUERY);
var ss = SpreadsheetApp.openByUrl(VENDORS_SPREADSHEET_URL);
var data = ss.getDataRange();
var rows = data.getNumRows();
var values = data.getValues();
for (var i = 0; i < rows; ++i) {
var row = values[i];
var vendor = row[VENDOR_NAME_INDEX];
var contacts = row[CONTACTS_INDEX];
var replied_back = row[HAS_REPLIED_INDEX];
var comments = row[COMMENTS_INDEX];
vendors.push({
name: vendor,
contacts: contacts,
replied_back: replied_back,
comments: comments
});
}
threads.forEach(function(thread) {
var id = thread.getId();
var subject = thread.getFirstMessageSubject();
var vendorName = subject.split("-")[0];
vendorName = vendorName.trimLeft();
vendorName = vendorName.trimRight();
var vendor = getVendorByName(vendorName);
if (typeof vendor == "object") {
if (vendor.replied_back.toLowerCase() != "yes") {
thread.replyAll("Friendly reminder...")
}
}
});
};
function getVendorByName(vendorName) {
for (var i = 0; i < vendors.length; ++i) {
if (vendors[i].name == vendorName) {
return vendors[i];
}
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.