1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| def mail_data(mFile) file = File.open(mFile).read mail = TMail::Mail.parse(file) idx = 1 mail.parts.each do |m| if nil != m['content-disposition'] m.base64_decode attach_fileNm = m['content-disposition']['filename'] File.open("#{CLIENTDATAPATH}/#{attach_fileNm}", 'w') do |f| f.write m.body end end idx += 1 end
CTYPE_TO_EXT = { 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/png' => 'png', 'image/tiff' => 'tiff', 'text/plain' => 'txt', 'application/vnd.ms-excel' => 'csv' }
def ext( mail ) CTYPE_TO_EXT[mail.content_type] || 'txt' end
|