Skip to content

Instantly share code, notes, and snippets.

@ravionrails
Created September 2, 2013 07:15
Show Gist options
  • Save ravionrails/6409990 to your computer and use it in GitHub Desktop.
Save ravionrails/6409990 to your computer and use it in GitHub Desktop.
in action----------
Mail.defaults do
retriever_method :imap,
:address => "imap.gmail.com",
:port => 993,
:user_name => 'email_id',
:password => '*******',
:enable_ssl => true
end
@mails = Mail.find(:what => :last, :order => :desc, :count => 10)
@mails = @mails.to_a
in view--------------------------
<% @mails.each do |mail| %>
<div class="border_bottom">
<% if mail.multipart?
email_html = mail.html_part.body #parsing of html content of the email
email_text = mail.text_part.body.decoded # parsing of text content of the email
else
email_html = mail.body # in this case its a plain email so html body is same as text body..
email_text = mail.body.decoded
email_attachments = [] # no attachments :)
end
%>
<%= email_html %>
</div>
<% end %>
Output------------------
</u><u></u></span></p><p class="MsoNormal"> <span lang="EN-US">Dear Sir/Madam,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u><u>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment