Abd*_*aly 5 javascript java gmail gmail-imap gmail-contextual-gadgets
我想将Gmail(Google Apps)中的电子邮件以及附件保存到另一个数据库,以实现类似CRM的功能.但是,根据文档,"提取器无法读取电子邮件附件".我的问题:是否有可能以某种方式使用电子邮件中的某种类型的标识符(例如EmailTimeExtractor)并使用它来使用IMAP提取附件?我对环境小工具还不是很熟悉,只是想知道在潜水太远之前我想做什么是可能的!
小智 1
如果您使用标准 imap 客户端拉取电子邮件,您将获得附件。这将是其中的一部分。伪代码:
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
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我是用 Perl 编写的,所以我使用 MIME::Tools 套件来保存电子邮件,并使用 IMAP::Client 作为我的 imap 客户端。但任何语言都应该有可用于表示 IMAP 连接和电子邮件的通用对象。