我收到以下错误:
Vpim::InvalidEncodingError (email@email.net):
2011-06-07T01:37:06+00:00 app[web.1]: .bundle/gems/ruby/1.8/gems/vpim-0.695/lib/vpim/field.rb:110:in `decode0'
它适用于其他电子名片。数据看起来正确——应该是一封电子邮件:
这是一个示例 vcard,当有一封电子邮件时它会爆炸……我所做的修复它是手动删除第二封电子邮件,但这很痛苦:
BEGIN:VCARD
VERSION:2.1
N:Roberts;Paul;;;
FN:Paul Roberts
ORG:Sonoma Technology Inc
TITLE:EVP Business Dev/Chief Scientific Officer
TEL;WORK;VOICE:707-665-9900
TEL;WORK;FAX:707-665-9800
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;1455 N McDowell Blvd Suite D;Petaluma;CA;94954;USA
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:1455 N McDowell Blvd Suite D=0D=0APetaluma, CA 94954=0D=0AUSA
URL:http://www.sonomatech.com
URL:http://www.sonomatech.com
EMAIL;PREF;INTERNET:paul@sonomatech.com
paul@sonomatech.com
NOTE;ENCODING=QUOTED-PRINTABLE:=0D=0A Data provided by Lead411, http://www.lead411.com/=0D=0A =0D=0A
END:VCARD
这是我使用回形针和 vpim 的控制器:
68 unless @contact.vcard.path.blank?
69
70 paperclip_vcard = File.new(@contact.vcard.path)
71
72 # try to scrub the vcard
73 scrub_vcf(paperclip_vcard)
74
75 @vcard = Vpim::Vcard.decode(paperclip_vcard).first
76 @contact.title = @vcard.title
77 @contact.email = @vcard.email
78 @contact.first_name = @vcard.name.given
79 @contact.last_name = @vcard.name.family
80 @contact.phone = @vcard.telephones[0]
81 @contact.fax = @vcard.telephones[1]
82
83 @contact.address.street1 = @vcard.address.street
84 @contact.address.city = @vcard.address.locality
85 @contact.address.state = @vcard.address.region
86 @contact.address.zip = @vcard.address.postalcode
87 @contact.company_name = @vcard.org.fetch(0)
88
89 end