Class: Rockdove::ExchangeMail
- Inherits:
-
Object
- Object
- Rockdove::ExchangeMail
- Extended by:
- Forwardable
- Defined in:
- lib/rockdove/exchange_mail.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#attachments ⇒ Object
Retrieve collection of attachments by accessing Rockdove::ExchangeMail @class_instance.attachments.
-
#body ⇒ Object
Retrieve parsed body content of the mail by accessing Rockdove::ExchangeMail @class_instance.body.
-
#cc_recipients ⇒ Object
Get a list of cc recipients by accessing Rockdove::ExchangeMail @class_instance.cc_recipients.
-
#date_time_created ⇒ Object
Retrieve date_time_created of the mail by accessing Rockdove::ExchangeMail @class_instance.date_time_created.
-
#date_time_sent ⇒ Object
Retrieve date_time_sent of the mail by accessing Rockdove::ExchangeMail @class_instance.date_time_sent.
-
#from ⇒ Object
Retrieve from email address by accessing Rockdove::ExchangeMail @class_instance.from.
-
#get_items(mail) ⇒ Object
Retrieves the mail item with text type body content.
-
#has_attachments? ⇒ Boolean
Has attachments boolean.
-
#initialize(mail_item, connection) ⇒ ExchangeMail
constructor
A new instance of ExchangeMail.
-
#parse_it(mail_body, type) ⇒ Object
This method parses the mail content provided @params of body and body_type.
-
#retrieve_text_type ⇒ Object
Retrieves text type body content of the mail.
-
#save_to_file(attachment, base_dir, file_name) ⇒ Object
Saves the attachment to a file by accessing Rockdove::ExchangeMail @class_instance.save_to_file with args attachment_object_from_rockdove::exchange_mail.attachments, base_dir, file_name.
-
#subject ⇒ Object
Retrieve subject of the mail by accessing Rockdove::ExchangeMail @class_instance.subject.
-
#to_recipients ⇒ Object
Get a list of to recipients by accessing Rockdove::ExchangeMail @class_instance.to_recipients.
Constructor Details
#initialize(mail_item, connection) ⇒ ExchangeMail
Returns a new instance of ExchangeMail.
15 16 17 18 |
# File 'lib/rockdove/exchange_mail.rb', line 15 def initialize(mail_item, connection) @mail_item = mail_item @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
13 14 15 |
# File 'lib/rockdove/exchange_mail.rb', line 13 def connection @connection end |
Instance Method Details
#attachments ⇒ Object
Retrieve collection of attachments by accessing Rockdove::ExchangeMail @class_instance.attachments
59 60 61 |
# File 'lib/rockdove/exchange_mail.rb', line 59 def @mail_item. end |
#body ⇒ Object
Retrieve parsed body content of the mail by accessing Rockdove::ExchangeMail @class_instance.body
41 42 43 44 45 46 |
# File 'lib/rockdove/exchange_mail.rb', line 41 def body content = "" mail = get_items(@mail_item) content = parse_it(mail.first.body, mail.first.body_type) unless mail.first.body.empty? content.force_encoding('UTF-8') end |
#cc_recipients ⇒ Object
Get a list of cc recipients by accessing Rockdove::ExchangeMail @class_instance.cc_recipients
26 27 28 |
# File 'lib/rockdove/exchange_mail.rb', line 26 def cc_recipients @mail_item.cc_recipients.collect &:email_address if @mail_item.cc_recipients end |
#date_time_created ⇒ Object
Retrieve date_time_created of the mail by accessing Rockdove::ExchangeMail @class_instance.date_time_created
73 74 75 |
# File 'lib/rockdove/exchange_mail.rb', line 73 def date_time_created @mail_item.date_time_created end |
#date_time_sent ⇒ Object
Retrieve date_time_sent of the mail by accessing Rockdove::ExchangeMail @class_instance.date_time_sent
78 79 80 |
# File 'lib/rockdove/exchange_mail.rb', line 78 def date_time_sent @mail_item.date_time_sent end |
#from ⇒ Object
Retrieve from email address by accessing Rockdove::ExchangeMail @class_instance.from
31 32 33 |
# File 'lib/rockdove/exchange_mail.rb', line 31 def from @mail_item.from.email_address if @mail_item.from end |
#get_items(mail) ⇒ Object
Retrieves the mail item with text type body content
49 50 51 |
# File 'lib/rockdove/exchange_mail.rb', line 49 def get_items(mail) @connection.get_items([mail.id], nil, {:item_shape => retrieve_text_type}) end |
#has_attachments? ⇒ Boolean
Has attachments boolean
54 55 56 |
# File 'lib/rockdove/exchange_mail.rb', line 54 def @mail_item. end |
#parse_it(mail_body, type) ⇒ Object
This method parses the mail content provided @params of body and body_type
83 84 85 |
# File 'lib/rockdove/exchange_mail.rb', line 83 def parse_it(mail_body, type) Rockdove::EmailParser.parse_mail(mail_body, type) end |
#retrieve_text_type ⇒ Object
Retrieves text type body content of the mail
88 89 90 |
# File 'lib/rockdove/exchange_mail.rb', line 88 def retrieve_text_type {:base_shape=>"AllProperties", :body_type=>"Text"} end |
#save_to_file(attachment, base_dir, file_name) ⇒ Object
Saves the attachment to a file by accessing Rockdove::ExchangeMail @class_instance.save_to_file with args attachment_object_from_rockdove::exchange_mail.attachments, base_dir, file_name
64 65 66 67 68 69 70 |
# File 'lib/rockdove/exchange_mail.rb', line 64 def save_to_file(, base_dir, file_name) base_dir << '/' unless(base_dir.nil? or base_dir.end_with?('/')) File.open("#{base_dir}#{file_name}", 'w+b') do |f| f.write(Base64.decode64(.content)) end true end |
#subject ⇒ Object
Retrieve subject of the mail by accessing Rockdove::ExchangeMail @class_instance.subject
36 37 38 |
# File 'lib/rockdove/exchange_mail.rb', line 36 def subject @mail_item.subject end |
#to_recipients ⇒ Object
Get a list of to recipients by accessing Rockdove::ExchangeMail @class_instance.to_recipients
21 22 23 |
# File 'lib/rockdove/exchange_mail.rb', line 21 def to_recipients @mail_item.to_recipients.collect &:email_address if @mail_item.to_recipients end |