22require 'mapi/property_set'
33
44module Mapi
5- =begin
6- # IMessage essentially, but there's also stuff like IMAPIFolder etc. so, for this to form
7- # basis for PST Item, it'd need to be more general.
8- class Item #< Msg
9- # IAttach
10- class Attachment #< Msg::Attachment
11- end
12-
13-
14- class Recipient #< Recipient
15- end
16-
17- # +props+ should be a PropertyStore object.
18- def initialize props
19- @properties = props
20- @mime = Mime.new props.transport_message_headers.to_s, true
21-
22- # hack
23- @root = OpenStruct.new(:ole => OpenStruct.new(:dirents => [OpenStruct.new(:time => nil)]))
24- populate_headers
25- end
26- end
27- =end
28-
295 class ObjectWithProperties
306 attr_reader :properties
317 alias props properties
@@ -100,6 +76,9 @@ def inspect
10076
10177 # i refer to it as a message (as does mapi), although perhaps Item is better, as its a more general
10278 # concept than a message
79+ #
80+ # IMessage essentially, but there's also stuff like IMAPIFolder etc. so, for this to form
81+ # basis for PST Item, it'd need to be more general.
10382 class Message < ObjectWithProperties
10483 # these 2 collections should be provided by our subclasses
10584 def attachments
@@ -110,43 +89,5 @@ def recipients
11089 raise NotImplementedError
11190 end
11291 end
113-
114- # the #to_mime logic will be refactored out into mapi/to_mime.rb
115- # will probably ditch custom Mime class, and go with TMail. to_mime.rb
116- # will include that mapping, as well as vcard, etc etc. or, i'll have
117- # mapi/to_mime/message.rb mapi/to_mime/vcard.rb mapi/to_mime/ical.rb
118- # i will add minimal functionality to the base classes beyond that.
119- # the msg parsing will be consolidated into mapi/msg.rb
120- # the pst parsing will go into mapi/pst.rb
121- # rtf related code will be in rtf.rb and mapi/rtf.rb
12292end
12393
124- #message = Mapi::Msg.open 'test-swetlana_novikova.msg'
125- #message = Mapi::Msg.open ARGV.first #'test-swetlana_novikova.msg'
126- #p message.props
127- #p message.props.message_class
128- #puts message.convert
129-
130- Mapi ::Msg . open 'test_Blammo.msg' do |msg |
131- puts msg . to_mime . to_tree
132- puts msg . to_mime . to_s
133- end if $0 == __FILE__
134-
135- __END__
136-
137- pst = Mapi::Pst.open 'test.pst'
138- message2 = pst.find { |m| m.path =~ /^inbox\/test/i and m.subject == 'test' }
139-
140- # what about conversion. i'm thinking something like:
141- # Mapi::PropertyStore#replace and/or #update
142- # and similarly, Message#replace. so you can do something like:
143-
144- message3 = Mapi::Msg.open 'test2.msg', 'rb+' # creates empty msg file
145- message3.update message2 # recursively copy all properties
146- message3.close
147-
148- # can define Message#to_msg as a shortcut to this. similarly, in the unlikely
149- # event that pst write support is ever implemented.
150-
151- # needs to be cheap to create a message, not like the current situation. ie, fully lazily loading.
152- # on the other hand, the inspect strings will probably cause things to be loaded, but thats ok.
0 commit comments