使用gmail上下文小工具访问附件 [英] Accessing attachments using gmail contextual gadgets

查看:97
本文介绍了使用gmail上下文小工具访问附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将电子邮件和附件从Gmail(Google Apps)保存到另一个类似CRM功能的数据库中。但是,根据文档,提取程序无法读取电子邮件附件。我的问题:是否有可能以某种方式使用电子邮件中的某种标识符(例如EmailTimeExtractor)并使用它来使用IMAP提取附件?我并不是很熟悉上下文的小工具,只是想知道我在尝试做的事情是否有可能在潜水之前做得太远! 解决方案

如果您使用标准的imap客户端将邮件拉下来,您将获得附件。这将是其中的一部分。伪代码:

  email = new-> email_object(); 
remote_mailbox = new-> imap_object_creator(用户名,密码,...)

while(email = remote_mailbox-> download_next_email){//这会下载下一封电子邮件
foreach part_type(email-> parts-> next){//这遍历电子邮件的部分
if(part_type =='attachment'){//不确定这是否完全正确,但是您会在mime类型
// hooray中找到它!你找到了一个附件。做你将要做的事



code


当我这样做时,我使用Perl编写它,所以我使用MIME :: Tools套件来保存电子邮件和IMAP :: Client作为我的imap客户端。但任何语言都应该有可用于表示IMAP连接和电子邮件的公共对象。


I'd like to save an email, along with attachments, from Gmail (Google Apps) to another database for CRM-like functionality. However, according to the docs, "Extractors can not read email attachments". My question: Is it possible to somehow use some type of identifier from the email (such as EmailTimeExtractor) and use that to pull the attachments using IMAP? I'm not very familiar with contextual gadgets yet and just wanted to know if what I'm trying to do is possible before diving in too far!

解决方案

If you use a standard imap client to pull the email down you'll get the attachment. It'll be one of the parts. Psuedo code:

email = new->email_object();
remote_mailbox = new->imap_object_creator(username, password, ...)

while (email = remote_mailbox->download_next_email) {  // this downloads the next email
  foreach part_type (email->parts->next) {    // this iterates over the parts of the email
    if( part_type == 'attachment' )  {  // not sure if this is it exactly, but you'll find it in the mime-type
      //hooray!  you've found an attachment.  do what you will with it
    }
  }
}

When I was doing this I was writing it in Perl so I used the MIME::Tools suite to hold the email and IMAP::Client as my imap client. But any language should have common objects available to represent an IMAP connection and an email.

这篇关于使用gmail上下文小工具访问附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆