Skip to content

Instantly share code, notes, and snippets.

@leepfrog
Created March 4, 2010 17:29
Show Gist options
  • Select an option

  • Save leepfrog/321928 to your computer and use it in GitHub Desktop.

Select an option

Save leepfrog/321928 to your computer and use it in GitHub Desktop.
>> a=File.open("testmsg.emlx")
=> #<File:testmsg.emlx>
>> mail=TMail::Mail.parse(a.read)
=> #<TMail::Mail port=#<TMail::StringPort:id=0x8525896c> bodyport=nil>
>> mail.body
=> "This E-mail was sent from (Aficio MP C2050)\nAttachment: 20100209163759213.pdf\n"
>> mail.body+="testing"
=> "This E-mail was sent from (Aficio MP C2050)\nAttachment: 20100209163759213.pdf\ntesting"
>> mail.body
=> ""
# ---
# Solved!
# ---
# This is kinda hoakey.. but it's how tmail is programmed. We need to step through each part of our multi-part message and append our add text
# if the current part's content_type is not an attachment... Not sure how this'll work with HTML email.
self.mail_message.parts.each do |part|
part.body+=add_txt unless part.disposition_is_attachment?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment