Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

rip calendar attachments from an email (in ruby) (See related posts)

See here for context.

I did this for undees

$: << '/home/username/usr/local/lib/ruby/site_ruby/1.8'
require 'tmail'

s = $
mail = TMail::Mail.parse s do |part|
  if 'text/calendar' == part.content_type
    t = part.body
    t.gsub!(/=[\r\n]+/, '')
    t.gsub!(/=(\w\w)/) {$1.hex.chr}
    outPath = '/home/username/path/to/Calendar.ics' outPath, 'w' do |f|
      f.write t
    File.chmod 0664, outPath    

You need to create an account or log in to post comments to this site.

Related Posts