diff --git a/lib/mapi/mime.rb b/lib/mapi/mime.rb index 3271de8..96c0b07 100644 --- a/lib/mapi/mime.rb +++ b/lib/mapi/mime.rb @@ -97,7 +97,12 @@ def to_s opts={} opts = {:boundary_counter => 0}.merge opts if multipart? boundary = Mime.make_boundary opts[:boundary_counter] += 1, self - @body = [preamble, parts.map { |part| "\r\n" + part.to_s(opts) + "\r\n" }, "--\r\n" + epilogue]. + #ensure that all parts are utf-8 + fallback = Hash.new {'?'} + fallback["\u2014"] = "-" + @body = [preamble, parts.map { |part| + "\r\n" + part.to_s(opts).encode('UTF-8', fallback: fallback) + "\r\n" + }, "--\r\n" + epilogue]. flatten.join("\r\n--" + boundary) content_type, attrs = Mime.split_header @headers['Content-Type'][0] attrs['boundary'] = boundary diff --git a/lib/mapi/version.rb b/lib/mapi/version.rb index e94f97c..0653d07 100644 --- a/lib/mapi/version.rb +++ b/lib/mapi/version.rb @@ -1,3 +1,3 @@ module Mapi - VERSION = '1.5.2' + VERSION = '1.5.3' end