simple_mapi.c File Reference

Convenience functions. More...

#include "libmapi/libmapi.h"
#include "libmapi/libmapi_private.h"

Functions

_PUBLIC_ enum MAPISTATUS AddUserPermission (mapi_object_t *obj_folder, const char *username, enum ACLRIGHTS role)
_PUBLIC_ enum MAPISTATUS GetBestBody (mapi_object_t *obj_message, uint8_t *format)
_PUBLIC_ enum MAPISTATUS GetDefaultFolder (mapi_object_t *obj_store, uint64_t *folder, const uint32_t id)
_PUBLIC_ enum MAPISTATUS GetDefaultPublicFolder (mapi_object_t *obj_store, uint64_t *folder, const uint32_t id)
_PUBLIC_ enum MAPISTATUS GetFolderItemsCount (mapi_object_t *obj_folder, uint32_t *unread, uint32_t *total)
_PUBLIC_ enum MAPISTATUS GetSpecialAdditionalFolder (mapi_object_t *obj_store, uint64_t *folder, const uint32_t id)
_PUBLIC_ bool IsMailboxFolder (mapi_object_t *obj_store, uint64_t fid, uint32_t *olFolder)
_PUBLIC_ enum MAPISTATUS ModifyUserPermission (mapi_object_t *obj_folder, const char *username, enum ACLRIGHTS role)
_PUBLIC_ enum MAPISTATUS RemoveUserPermission (mapi_object_t *obj_folder, const char *username)

Detailed Description

Convenience functions.

Function Documentation

◆ AddUserPermission()

_PUBLIC_ enum MAPISTATUS AddUserPermission ( mapi_object_t * obj_folder,
const char * username,
enum ACLRIGHTS role )

Adds permissions for a user on a given folder

Parameters
obj_folderthe folder we add permission for
usernamethe Exchange username we add permissions for
rolethe permission mask value

The following permissions and rights are supported:

  • RightsNone
  • RightsReadItems
  • RightsCreateItems
  • RightsEditOwn
  • RightsDeleteOwn
  • RightsEditAll
  • RightsDeleteAll
  • RightsCreateSubfolders
  • RightsFolderOwner
  • RightsFolderContact
  • RoleNone
  • RoleReviewer
  • RoleContributor
  • RoleNoneditingAuthor
  • RoleAuthor
  • RoleEditor
  • RolePublishAuthor
  • RolePublishEditor
  • RightsAll
  • RoleOwner
Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: username is NULL
See also
ResolveNames, ModifyPermissions

References MAPIFreeBuffer(), ModifyPermissions(), and ResolveNames().

◆ GetBestBody()

_PUBLIC_ enum MAPISTATUS GetBestBody ( mapi_object_t * obj_message,
uint8_t * format )

Implement the BestBody algorithm and return the best body content type for a given message.

Parameters
obj_messagethe message we find the best body for
formatthe format - see below.
Returns
MAPI_E_SUCCESS on success, otherwise MAPI_E_NOT_FOUND. If MAPI_E_NOT_FOUND is returned then format is set to 0x0 (undefined). If MAPI_E_SUCCESS is returned, then format can have one of the following values:
  • olEditorText: format is plain text
  • olEditorHTML: format is HTML
  • olEditorRTF: format is RTF

References GetProps(), and MAPIFreeBuffer().

◆ GetDefaultFolder()

_PUBLIC_ enum MAPISTATUS GetDefaultFolder ( mapi_object_t * obj_store,
uint64_t * folder,
const uint32_t id )

Retrieves the folder id for the specified default folder in a mailbox store

Parameters
obj_storethe store to search
idthe type of folder to search for
folderthe resulting folder reference

The following types of folders are supported:

  • olFolderTopInformationStore
  • olFolderDeletedItems
  • olFolderOutbox
  • olFolderSentMail
  • olFolderInbox
  • olFolderCommonView
  • olFolderCalendar
  • olFolderContacts
  • olFolderJournal
  • olFolderNotes
  • olFolderTasks
  • olFolderDrafts
  • olFolderReminders
  • olFolderFinder

Note that this function will cache FID values for common accessed folders such as calendar, contact, journal, note, task and drafts until the store object got released.

Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: obj_store is undefined
  • MAPI_E_NOT_FOUND: The specified folder could not be found or is not yet supported.
See also
MAPIInitialize, OpenMsgStore, GetLastError

◆ GetDefaultPublicFolder()

_PUBLIC_ enum MAPISTATUS GetDefaultPublicFolder ( mapi_object_t * obj_store,
uint64_t * folder,
const uint32_t id )

Retrieve the folder id for the specified default folder in a public folder store

Parameters
obj_storethe store to search
idthe type of folder to search for
folderthe resulting folder reference

The following types of folders are supported:

  • olFolderPublicRoot - the parent (directly or indirectly) for the folders below
  • olFolderPublicIPMSubtree - Interpersonal Messages (IPM) folders
  • olFolderPublicNonIPMSubtree - Non-interpersonal message folders
  • olFolderPublicEFormsRoot - EForms Registry Root Folder
  • olFolderPublicFreeBusyRoot - Free/busy root folder
  • olFolderPublicOfflineAB - Offline address book root folder
  • olFolderPublicEFormsRegistry - EForms Registry for the users locale
  • olFolderPublicLocalFreeBusy - Site local free/busy folders
  • olFolderPublicLocalOfflineAB - Site local Offline address book
  • olFolderPublicNNTPArticle - NNTP article index folder
Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: obj_store is undefined
  • MAPI_E_NOT_FOUND: The specified folder could not be found or is not yet supported.
See also
MAPIInitialize, OpenPublicFolder, GetLastError

◆ GetFolderItemsCount()

_PUBLIC_ enum MAPISTATUS GetFolderItemsCount ( mapi_object_t * obj_folder,
uint32_t * unread,
uint32_t * total )

Retrieves the total and unread number of items for a specified folder.

Parameters
obj_folderthe folder to get item counts for
unreadthe number of items in the folder (result)
totalthe number of items in the folder, including unread items (result)
Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: obj_folder is undefined
  • MAPI_E_NOT_FOUND: The specified folder could not be found or is not yet supported.
See also
MAPIInitialize, OpenFolder, GetLastError

References GetProps(), and MAPIFreeBuffer().

◆ GetSpecialAdditionalFolder()

_PUBLIC_ enum MAPISTATUS GetSpecialAdditionalFolder ( mapi_object_t * obj_store,
uint64_t * folder,
const uint32_t id )

Retrieves the folder id for the specified special folder for a mailbox store from PidTagAdditionalRenEntryIDs property in Inbox folder.

Parameters
obj_storethe store to search
idthe type of folder to search for
folderthe resulting folder reference

The following types of folders are supported:

  • olFolderSyncIssues
  • olFolderLocalFailures
  • olFolderServerFailures
  • olFolderJunk

Note that this function will cache FID values until the store object got released.

Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: obj_store is undefined or the given id is not stored as AdditionalRenEntryID
See also
MAPIInitialize, OpenMsgStore, GetLastError

◆ IsMailboxFolder()

_PUBLIC_ bool IsMailboxFolder ( mapi_object_t * obj_store,
uint64_t fid,
uint32_t * olFolder )

Check if a given folder identifier matches with a system/default one and optionally returns the olFolder type

Parameters
obj_storepointer to the store object
fidreference to the folder identifier to check
olFolderpointer to the returned olFolder
Returns
true on success, otherwise false

◆ ModifyUserPermission()

_PUBLIC_ enum MAPISTATUS ModifyUserPermission ( mapi_object_t * obj_folder,
const char * username,
enum ACLRIGHTS role )

Modify permissions for a user on a given folder

Parameters
obj_folderthe folder to modify permissions for
usernamethe Exchange username to modify permissions for
rolethe permission mask value (see AddUserPermission)
Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: username is NULL
  • MAPI_E_NOT_FOUND: couldn't find or change permissions for the given user
See also
AddUserPermission, ResolveNames, GetPermissionsTable, ModifyPermissions

References GetPermissionsTable(), MAPIFreeBuffer(), ModifyPermissions(), QueryPosition(), QueryRows(), ResolveNames(), and SetColumns().

◆ RemoveUserPermission()

_PUBLIC_ enum MAPISTATUS RemoveUserPermission ( mapi_object_t * obj_folder,
const char * username )

Remove permissions for a user on a given folder

Parameters
obj_folderthe folder to remove permission from
usernamethe Exchange username to remove permissions for
Returns
MAPI_E_SUCCESS on success, otherwise a failure code (MAPISTATUS) indicating the error.
Note
Developers may also call GetLastError() to retrieve the last MAPI error code. Possible MAPI error codes are:
  • MAPI_E_NOT_INITIALIZED: MAPI subsystem has not been initialized.
  • MAPI_E_INVALID_PARAMETER: username or obj_folder are NULL
  • MAPI_E_NOT_FOUND: couldn't find or remove permissions for the given user
See also
ResolveNames, GetPermissionsTable, ModifyPermissions

References GetPermissionsTable(), MAPIFreeBuffer(), ModifyPermissions(), QueryPosition(), QueryRows(), ResolveNames(), and SetColumns().


Creative Commons License
Creative Commons Attribution icon Creative Commons Share Alike icon
This content is licensed under the Creative Commons
Attribution ShareAlike License v. 3.0:
http://creativecommons.org/licenses/by-sa/3.0/