Hi, i am using RMail to receive incoming email. But my application could
not handle html content because sometime the email contains HTML
content. So i got to remove or ignore the HTML content. But i got
problem with it. So mind helping. Thanks Anyway below is my RMail
application. Thanks
File.open(Pathname.new(ARGV[0]), ''r'') do |mbox|
RMail::Mailbox.parse_mbox(mbox) do |raw|
count += 1
print "Mail #{count}\n"
message = RMail::Parser.read(raw)
msisdn = message.header[''From'']
to = message.header[''To'']
datetime = message.header[''Date'']
date = ((DateTime.parse(datetime)).strftime(fmt=''%Y-%m-%e
%H:%M:%S'')
)
print "From: " + message.header[''From''] +
"\n"
print "To: " + message.header[''To''] +
"\n"
print "Date: " + message.header[''Date''] +
"\n"
if (message.header[''Subject''])
print "Subject: " + message.header[''Subject'']
+ "\n"
end
i = 0
message.each_part { |part|
i += 1
str = part.decode()
doc = Document.new(str)
if (doc.root == nil)
print "Description: #{str}\n"
desc = str
else
doc.elements.each("*/lm:landmarkCollection") { |element|
name =
element.elements["lm:landmark/lm:name"].get_text.value
latitude
element.elements["lm:landmark/lm:coordinates/lm:latitude"].get_text.value
longitude
element.elements["lm:landmark/lm:coordinates/lm:longitude"].get_text.value
street
element.elements["lm:landmark/lm:addressInfo/lm:street"].get_text.value
postal_code
element.elements["lm:landmark/lm:addressInfo/lm:postalCode"].get_text.value
city
element.elements["lm:landmark/lm:addressInfo/lm:city"].get_text.value
country
element.elements["lm:landmark/lm:addressInfo/lm:country"].get_text.value
print "Landmark:\n"
print "\tName: #{name}\n"
print "\tLatitude: #{latitude}\n"
print "\tLongitude: #{longitude}\n"
print "Address:\n"
print "\tStreet: #{street}\n"
print "\tPostal Code: #{postal_code}\n"
print "\tCity: #{city}\n"
print "\tCountry: #{country}\n"
}
end
}
print "\n"
# AssetSubmitHandler::receive(raw)
end
end
Wawa
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---