Ruby Requires Chilkat v11.0.0+
Ruby
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat Ruby Downloads
require 'chilkat'
success = false
# Assumes Chilkat is unlocked. See Global Unlock Sample.
wrapper = Chilkat::CkEmail.new()
success = wrapper.LoadEml("forward-as-attachment.eml")
if (success != true)
print wrapper.lastErrorText() + "\n";
exit
end
print "Cover note: " + wrapper.subject() + "\n";
if (wrapper.get_NumAttachedMessages() == 0)
print "No attached messages." + "\n";
exit
end
nested = Chilkat::CkEmail.new()
i = 0
while (i < wrapper.get_NumAttachedMessages())
success = wrapper.GetAttachedEmail(i,nested)
if (success != true)
print wrapper.lastErrorText() + "\n";
exit
end
print "Original author: " + nested.ck_from() + "\n";
print "Original subject: " + nested.subject() + "\n";
print "Files on the original: " + nested.get_NumAttachments().to_s() + "\n";
i = i + 1
end