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, helper) ⇒ Attachment

Returns a new instance of Attachment.

Parameters:

  • obj (Ole::Storage::Dirent)
  • helper (Helper)


448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/mapi/msg.rb', line 448

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

	super PropertySet.new(PropertyStore.load(@obj, helper))
	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, helper
			end
		end
	end
end

Instance Attribute Details

#propertiesPropertySet (readonly) Also known as: props

Returns:



442
443
444
# File 'lib/mapi/msg.rb', line 442

def properties
  @properties
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


484
485
486
487
488
# File 'lib/mapi/msg.rb', line 484

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