开发者

Accessing attachments using gmail contextual gadgets

开发者 https://www.devze.com 2023-01-08 08:48 出处:网络
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

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 开发者_StackOverflow社区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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消