3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/mail_alternatives_with_attachments/mail_message_alternative_content_types_with_attachment.rb', line 3
def alternative_content_types_with_attachment(options, &block)
text_alternative = Mail::Part.new do
content_type "text/plain; charset=UTF-8"
body options[:text]
end
html_alternative = Mail::Part.new do
content_type 'text/html; charset=UTF-8'
body options[:html]
end
html_container = Mail::Part.new { content_type 'multipart/related' }
html_container.add_part html_alternative
alternative_bodies = Mail::Part.new { content_type 'multipart/alternative' }
alternative_bodies.add_part text_alternative
alternative_bodies.add_part html_container
add_part alternative_bodies
if block_given?
yield(html_container.attachments)
end
return self
end
|