Accessing attachments using gmail contextual gadgets

守給你的承諾、 提交于 2019-12-21 05:05:39

问题


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!


回答1:


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.




回答2:


I believe Attachments.me does exactly this - does that help, or is your need still unmet?




回答3:


It should be possible to get the email Id from the extractor, then use google apps script GmailAttachment object to get the attachment.



来源:https://stackoverflow.com/questions/3296329/accessing-attachments-using-gmail-contextual-gadgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!