message::attachment_begin throws exception when message contains no attachments


When a message legitimately contains no attachments, the message::attachment_begin property raises a key_not_found exception. It seems reasonable to expect 'attachment_begin() == attachment_end()' so that clients need not test for the presence of attachments before using the iteration interface.
Exception is raised due to failed lookup in the call to 'reset' (see below).
inline const pstsdk::table& pstsdk::message::get_attachment_table() const
    m_attachment_table.reset(new table(m_bag.get_node().lookup(nid_attachment_table)));
return *m_attachment_table;


glyph wrote May 10, 2011 at 6:33 PM

This appears to be intended behavior. The body of message::get_attachment_count is enclosed in a try...catch block allowing clients to safely check for the attachments prior to iteration. Feel free to remove this post (or file as non-essential).

wrote Feb 14, 2013 at 9:08 PM