Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
Send any exceptions in encoding to Idobata
Browse files Browse the repository at this point in the history
  • Loading branch information
yasulab committed Oct 1, 2019
1 parent 47a5c1a commit 4a735d7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions gmail2idobata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ def attached_file_exist?(filename)
text += "<b>#{mail.subject.toutf8}</b><br>"
end

#件名、日付、From、To、本文処理
if !mail.text_part && !mail.html_part
text += mail.body.decoded.encode('UTF-8', mail.charset, invalid: :replace, undef: :replace)
elsif mail.html_part
text += mail.html_part.decoded
is_html_format = true
elsif mail.text_part
text += mail.text_part.decoded
begin
#件名、日付、From、To、本文処理
if !mail.text_part && !mail.html_part
text += mail.body.decoded.encode('UTF-8', mail.charset, invalid: :replace, undef: :replace)
elsif mail.html_part
text += mail.html_part.decoded
is_html_format = true
elsif mail.text_part
text += mail.text_part.decoded
end
rescue => e
# エンコーディングで例外が発生したら、それも通知する
text += e.message
end

post = text.gsub("\n", "").gsub("'", "\"")
Expand Down

0 comments on commit 4a735d7

Please sign in to comment.