3 Message class implementation
5 Copyright (C) Alan Alvarez 2008.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <libmapi++/attachment.h>
25 message::attachment_container_type message::fetch_attachments()
27 mapi_object_t attachment_table;
29 mapi_object_init(&attachment_table);
30 if (GetAttachmentTable(&m_object, &attachment_table) != MAPI_E_SUCCESS) {
31 mapi_object_release(&attachment_table);
32 throw mapi_exception(GetLastError(), "message::fetch_attachments : GetAttachmentTable");
35 SPropTagArray* property_tag_array = set_SPropTagArray(m_session.get_memory_ctx(), 0x1, PR_ATTACH_NUM);
37 if (SetColumns(&attachment_table, property_tag_array) != MAPI_E_SUCCESS) {
38 MAPIFreeBuffer(property_tag_array);
39 mapi_object_release(&attachment_table);
40 throw mapi_exception(GetLastError(), "message::fetch_attachments : SetColumns");
43 MAPIFreeBuffer(property_tag_array);
46 attachment_container_type attachment_container;
48 while( (QueryRows(&attachment_table, 0x32, TBL_ADVANCE, &row_set) == MAPI_E_SUCCESS) && row_set.cRows) {
49 for (unsigned int i = 0; i < row_set.cRows; ++i) {
51 attachment_container.push_back(attachment_shared_ptr(new attachment(*this, row_set.aRow[i].lpProps[0].value.l)));
53 catch(mapi_exception e) {
54 mapi_object_release(&attachment_table);
59 mapi_object_release(&attachment_table);
61 return attachment_container;
64 } // namespace libmapipp