Class: Mapi::Msg::Attachment

Inherits:
Attachment show all
Defined in:
lib/mapi/msg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Attachment

#data, #filename, #inspect, #save, #to_mime, #to_tmail

Constructor Details

#initialize(obj) ⇒ Attachment

Returns a new instance of Attachment.



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/mapi/msg.rb', line 387

def initialize obj
	@obj = obj
	@embedded_ole = nil
	@embedded_msg = nil

	super PropertySet.new(PropertyStore.load(@obj))
	Msg.warn_unknown @obj

	@obj.children.each do |child|
		# temp hack. PropertyStore doesn't do directory properties atm - FIXME
		if child.dir? and child.name =~ PropertyStore::SUBSTG_RX and
			 $1 == '3701' and $2.downcase == '000d'
			@embedded_ole = child
			class << @embedded_ole
				def compobj
					return nil unless compobj = self["\001CompObj"]
					compobj.read[/^.{32}([^\x00]+)/m, 1]
				end

				def embedded_type
					temp = compobj and return temp
					# try to guess more
					if children.select { |child| child.name =~ /__(substg|properties|recip|attach|nameid)/ }.length > 2
						return 'Microsoft Office Outlook Message'
					end
					nil
				end
			end
			if @embedded_ole.embedded_type == 'Microsoft Office Outlook Message'
				@embedded_msg = Msg.new @embedded_ole
			end
		end
	end
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



384
385
386
# File 'lib/mapi/msg.rb', line 384

def obj
  @obj
end

#propertiesObject (readonly) Also known as: props

Returns the value of attribute properties.



384
385
386
# File 'lib/mapi/msg.rb', line 384

def properties
  @properties
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


422
423
424
425
426
# File 'lib/mapi/msg.rb', line 422

def valid?
	# something i started to notice when handling embedded ole object attachments is
	# the particularly strange case where there are empty attachments
	not props.raw.keys.empty?
end