PHP-MAPI extension

Zarafa

Version 6.10 - 6.30


Table of Contents

1. Introduction
Summary — An introduction to the PHP MAPI Extension
2. Programming
Properties — Explanation of MAPI properties.
Checking Errors — How to handle errors from the extension.
Restrictions — Using restrictions on tables.
Attachments — Adding attachments to messages.
Messages — Reading messages.
Recipients — Using the recipient table.
3. PHP-MAPI Reference
General Functions — Functions that are not directly MAPI related.
Logon Functions — This section describes the various logon functions.
Store Functions — This section describes functions which are performed on MAPI Store objects.
Folder Functions — This section describes functions which are performed on MAPI Folder objects.
Table Functions — This section describes functions which are performed on MAPI Table objects.
Rules Functions — This section describes functions which are performed on the rules table.
Message Functions — This section describes functions which are performed on MAPI Message objects.
Attachment Functions — This section describes functions which are performed on MAPI Attachment objects.
Stream Functions — This section describes functions to create streams to objects and how to use these streams.
Addressbook Functions — This section describes functions to use the addressbook for user and e-mail address lookups.
Freebusy Functions — This section describes freebusy specific functions to see the freebusy data of the users.
Zarafa specific text functions — This section describes special functions used to handle texts of a mailbody.
Zarafa specific functions — This section describes Zarafa specific functions to manage users and groups and get and set permissions on folders.

List of Examples

2.1. Property definitions
2.2. Checking property errors in an object
2.3. Checking for errors or warnings
2.4. Checking last MAPI returned error code
2.5. Simple restriction example
2.6. RES_SUBRESTRICTION + RES_COMMENT example
2.7. Recipient table
3.1. Checking an error
3.2. Checking the last MAPI HRESULT
3.3. Creating an SCODE error value
3.4. Getting the ID of a propertytag
3.5. Getting the type of a propertytag
3.6. Making a PR_SUBJECT
3.7. Mapping start and end named properties for calendar items
3.8. Get names from IDs
3.9. Getting the properties of a store
3.10. Setting the properties of a message
3.11. Copying the properties of a message
3.12. Saving changes to a message
3.13. Deleting a property of a message
3.14. Getting a property
3.15. Creating a one-off entry identifier
3.16. Listing the Zarafa users
3.17. Logging on to the default profile
3.18. Logging on to the Zarafa server using the unix socket
3.19. Logging on to a PST-file
3.20. Opening the stores of a Zarafa session
3.21. Getting the table with the stores
3.22. Opening a Zarafa message store
3.23. Opening multiple Zarafa message stores
3.24. Opening multiple Zarafa message stores
3.25. Opening the inbox of a store
3.26. Opening an entry from a messagestore
3.27. Opening a Zarafa message store
3.28. Opening the special multistore table
3.29. Getting the hierarchytable
3.30. Getting the getcontentstable
3.31. Creating a new message
3.32. Creating and removing a message
3.33. Moving messages to the wastebasket
3.34. Emptying a folder
3.35. Move a complete folder, with subtree, to a new destination
3.36. Deleting a folder
3.37. Creating a folder
3.38. Marking messages in a folder read
3.39. Requesting the IExchangeModifyTable interface
3.40. Reading the rows from a table
3.41. Reading the rows from a table
3.42. Getting the the rows one by one from a table
3.43. Sorting and retrieving the rows of a table by subject
3.44. Restriction on a mapitable
3.45. Retrieving the rules table
3.46. Modifying the rules table
3.47. Marking all messages as read in the inbox
3.48. Opening the attachmenttable of a message
3.49. Opening a recipienttable
3.50. Modifying recipients
3.51. Opening an attachment
3.52. Creating an attachment
3.53. Deleting an attachment
3.54. Submitting a message
3.55. Getting attachment data
3.56. Getting the attachment message
3.57. Reading a stream
3.58. Creating a new stream
3.59. Reading from a stream
3.60. Seeking in a stream
3.61. Setting the size of a stream
3.62. Committing a stream
3.63. Writing data into a stream
3.64. Getting the statistics from a stream
3.65. Open the Addressbook
3.66. Requesting the top-level AddressBook container
3.67. Resolving a user to e-mail address
3.68. Opening the default Addressbook Directory
3.69. Open a freebusysupport object
3.70. Close a freebusysupport object
3.71. Get freebusydata object of one user
3.72. Get freebusyupdate object of one user
3.73. Get freebusy enumblock object of one user and read some data
3.74. Get freebusy publish range
3.75. Sets the freebusy range of time.
3.76. Sets the cursor to the beginning
3.77. Skips 2 blocks of free/busy data.
3.78. Restricts the enumeration to a specified time period.
3.79. Gets the next 10 blocks of free/busy data.
3.80. Remove all current free/busy data
3.81. Publish 2 blocks of free/busy data
3.82. Save the free/busy data
3.83. Decompress a RTF body
3.84. Decoding RTF
3.85. Encoding HTML
3.86. Compress an RTF body
3.87. Creating a user
3.88. Setting user information
3.89. Creating a store
3.90. Deleting a user
3.91. Listing the Zarafa users
3.92. Getting user information
3.93. Getting user information
3.94. Getting group information
3.95. Getting group information
3.96. Changing group information
3.97. Listing groups
3.98. Creating a group
3.99. Deleting a group
3.100. Adding a user to a group
3.101. Deleting a user from a group
3.102. Getting groups of a user
3.103. Getting users of a group
3.104. Creating a company
3.105. Deleting a company
3.106. Getting company information
3.107. Getting company information
3.108. Listing companies
3.109. Add a company to the remote view list of a different company
3.110. Delete a company from the remote view list of a different company
3.111. List all companies in the remote view list
3.112. Add a user to the remote admin list of a different company
3.113. Delete a user from the admin list of a company
3.114. List all users in the remote admin list
3.115. Add a recipient to the recipient list of a company
3.116. Delete a recipient from the recipient list of a company
3.117. List all users in the recipient list
3.118. Getting the ACL list of the store.
3.119. Setting the ACL list on the inbox.

Chapter 1. Introduction

Table of Contents

Summary — An introduction to the PHP MAPI Extension

Name

Summary — An introduction to the PHP MAPI Extension

Purpose

The PHP-MAPI extension provides access to MS MAPI function from php. Although not all MAPI functions and interfaces are supported, most functions have a php counterpart in this extension. Using PHP-MAPI, users can create webbased e-mail and calendaring systems and interfaces with existing php projects, using the mapi functions like a normal mapi program.

Other documentation

The complete PHP-MAPI extension was based on the MAPI specification by Microsoft, which can be downloaded from MSDN at no charge. The functions defined in chapter 2, the php-mapi reference, are usually directly related to their MAPI counterpart and most information provided by the Microsoft MAPI specification is also applicable to the functions defined in the reference.

Also, general MAPI practices, hierarchies and properties apply to the PHP-MAPI extension. You are assumed to have basic knowledge of MAPI and its object structure before reading this reference manual.

Unsupported features

Current unsupported features of MAPI are:

  • The IProfAdmin interface and related interfaces

  • Notifications, interfaces and related functions

  • Search folders: creation and use of

  • Unicode string properties (read/write, except for named properties which are always Unicode)

  • Folder and message operations: copyTo etc.

New features

Additional features since 4.1 are:

  • Selected Addressbook functions (IAddrBook and others)

  • SetReadFlags function on a MAPI folder was added

  • GetNamesFromIDs function for named properties was added

  • IExchangeModifyTable interface support

  • Zarafa specific admin functions to create users, groups and adminster them

  • Zarafa specific permission functions to get and set permissions on items

  • Ability to get the last occurred HRESULT from the called mapi functions

Latest version

The latest version of this document can be downloaded from http://developer.zarafa.com/

Chapter 2. Programming

Table of Contents

Properties — Explanation of MAPI properties.
Checking Errors — How to handle errors from the extension.
Restrictions — Using restrictions on tables.
Attachments — Adding attachments to messages.
Messages — Reading messages.
Recipients — Using the recipient table.

This chapter will describe the PHP-MAPI API and how to use it. It will describe also some tricks that can be applied to make programming easier.

Name

Properties — Explanation of MAPI properties.

— Explanation of MAPI properties.

Properties

Every object in MAPI has several properties set. The properties contains information about the object like the name, the unique id, etc... A property tag consists of a type and a unique id, the property type and the property id. A property tag is made as in the following example:

Example 2.1. Property definitions

define ('PR_SUBJECT', mapi_prop_tag(PT_TSTRING, 0x0037);
// This will result in a constant PR_SUBJECT with the value 0x001E0037
		

Within the PHP-code all of the properties are defined with a PR_ prefix to indicatie it is a PRoperty. All type codes are prefixed with PT_ (Property Type).

The function mapi_prop_tag accepts the property type and the property id and returns a unique code that indicates the property tag. This code is a simple long where the first 16 bits are the type and the last 16 bits are the ID.

Possible property types are:

PT_NULL, PT_ERROR

Single properties
PT_I2, PT_LONG, PT_FLOAT, PT_DOUBLE, PT_APPTIME, PT_BOOLEAN,
PT_STRING8, PT_SYSTIME, PT_BINARY, PT_CLSID

Multi value properties
PT_MV_I2, PT_MV_LONG, PT_MV_R4, PT_MV_DOUBLE, PT_MV_APPTIME
PT_MV_SYSTIME, PT_MV_STRING8, PT_MV_BINARY, PT_MV_CLSID

Not support:
PT_CURRENCY, PT_UNICODE, PT_OBJECT, PT_I8
PT_MV_CURRENCY, PT_MV_UNICODE, PT_MV_I8

Special properties for rules table:
PT_ACTIONS and PT_SRESTRICTION
	  

Name

Checking Errors — How to handle errors from the extension.

Checking errors

When an array of properties is retrieved with the function mapi_getprops by example there could some problems with the properties. Because of optimalization MAPI has a restricition on the size of a property. When by example a PR_BODY is too big the error MAPI_E_NOT_ENOUGH_MEMORY will be returned instead of the actual data.

The type of this property will be set to PT_ERROR instead of PT_TSTRING. The value of the property will be the code of the error that occured. The numeric value of the property tag will be 0x000A0037 which is different from 0x001E0037. This requires a special way to check if there is an error and find out what the error code is.

The following program listing gives an example how to check the property on an error and how to get the error from the property:

Example 2.2.  Checking property errors in an object

// get properties
$msg_props = mapi_getprops($message);
 
if (array_key_exists($msg_props, PR_BODY) {
   // there is a body with no error, display body here
} else {
   $pr_body_error = mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_BODY));
   if (array_key_exists($msg_props, $pr_body_error)) {
      // found an error, now check which
      switch($msg_props[$pr_body_error]) {
         case MAPI_E_NOT_ENOUGH_MEMORY:
            // found but too big, use mapi_openproperty the get the data. 
         break; 
         default:
            // other error. 
         break;
      }
   } else {
      // No error found, the body doesn't exist in this object.
   } 
}
		  

Also, when checking error values (such as 0x80040107, MAPI_E_NOT_FOUND), you must use the mapi_is_error function to check whether the valus is actually an error. This is due to the fact that 0x800xxxxx numbers are not handed as unsigned numbers within PHP.

Example 2.3.  Checking for errors or warnings

if(mapi_is_error($msg_props[$pr_body_error])) {
  echo "error!\n";
}
		  

When a function returns the value 'false', it means the function has failed. To retrieve the MAPI error, you can use the mapi_last_hresult() function, to get the last returned HRESULT value of a MAPI function. Example:

Example 2.4.  Checking last MAPI returned error code

$inbox = mapi_msgstore_getreceivefolder($store);
if ($inbox == false) {
	print "no inbox available!\n";
	printf("last result: %x\n",mapi_last_hresult());
}
		  


Name

Restrictions — Using restrictions on tables.

Restrictions

Restrictions limit the rows queried using a set of conditions. This way messages can be selected on specific properties, such as the existance of a certain property, a property's value larger than a certain value, etc..

A restriction is specified with an array with one value with the restriction type and one value with an array with the restriction specific properties.

Restriction types:

RES_AND

Takes an array with restrictions that must all be valid.

RES_OR

Expects an array with restrictions of which either one can be valid.

RES_NOT

Wants an array with a single restriction that must not be valid.

RES_CONTENT

Fuzzy search a property. The array must contain: FUZZYLEVEL, ULPROPTAG and VALUE. VALUE must be a string or binary. VALUE => array (tag => value)

RES_PROPERTY

Takes an array with properties of a property which must be valid. This array must contain: RELOP, ULPROPTAG and VALUE. The property and VALUE can have different types. VALUE => array (tag => value)

RES_COMPAREPROPS

Compares two props. Expects an array with the indexes: RELOP, ULPROPTAG1 and ULPROPTAG2.

RES_BITMASK

Applies a bitmask. The given array must contain: ULPROPTAG, ULTYPE and ULMASK.

RES_SIZE

Measures the size of a property. The array must have: ULPROPTAG, RELOP and CB.

RES_EXIST

Checks whether a property exists. Takes only ULPROPTAG in its array.

RES_SUBRESTRICTION

Places a restriction on a property. This is used on PR_MESSAGE_RECIPIENT properties with an RES_COMMENT restriction.

RES_COMMENT

A comment restriction can be used to add comments to the restriction structure, or in a special case with the RES_SUBRESTRICTION. The RES_COMMENT structure holds a RES_PROPERTY restriction, which applies on the given properties list in the structure.

RELOP can be:

RELOP_LT

Less than.

RELOP_LE

Less than or equal to.

RELOP_GT

Greater than.

RELOP_GE

Greater than or equal to.

RELOP_EQ

Equal to.

RELOP_NE

Not equal to.

RELOP_RE

The attachment has just been created.

FUZZYLEVEL can be one or bitwise more of these:

FL_FULLSTRING

The property must be equal to this exact string.

FL_SUBSTRING

Full text search for substring.

FL_PREFIX

The value must start with this string.

FL_IGNORECASE

Case should be ignored.

FL_IGNORENONSPACE

Non-spaces should be ignored.

FL_LOOSE

The string is allowed to match loosely.

Example 2.5. Simple restriction example

// Example for restrictions
$testrestriction = Array(RES_OR,
                     Array(Array(RES_PROPERTY,
                                 Array(RELOP => RELOP_LE,
                                       ULPROPTAG => PR_BODY,
                                       VALUE => array(PR_BODY =>"test") )),
                           Array(RES_PROPERTY,
                                 Array(RELOP => RELOP_LE,
                                       ULPROPTAG => PR_SUBJECT,
                                       VALUE => array(PR_SUBJECT => "bericht")))));
$contents = mapi_table_queryallrows($table, $props, $sizerestriction);

foreach ($contents as $row)
{
        echo $row[PR_SUBJECT];
        echo "\n";
}
		

Example 2.6. RES_SUBRESTRICTION + RES_COMMENT example

$restriction =
	array(RES_SUBRESTRICTION,
		array(ULPROPTAG => PR_MESSAGE_RECIPIENTS, // this is the subobject
			  RESTRICTION => array(RES_COMMENT,
				array(PROPS => array(),	// probably need to add outlook data
					  RESTRICTION => array(RES_PROPERTY,
						 array(RELOP => RELOP_EQ,
							   ULPROPTAG => PR_SEARCH_KEY,
							   VALUE => array(PR_SEARCH_KEY => "one-off entryid") )
					  )
				)
			)
		)
	);
		


Name

Attachments — Adding attachments to messages.

Attachments

Attachments are used to send a binary file with a email message. There are a few different attachments types.

ATTACH_BY_VALUE, the attachment data is stored within the message object.
ATTACH_EMBEDDED_MSG, the attachment is stored as a message object within the message object.
ATTACH_BY_REFERENCE, ATTACH_BY_REF_RESOLVE and ATTACH_BY_REF_ONLY are references to a file by name. Since the PHP code runs on the server, these types are unsupported.

All of these types use different ways to store the name and to store the attachement data. with mapi_message_getattachmenttable() the table with all the attachments can be read from the message. Every row in this table has a property PR_ATTACH_METHOD which defines with which method the attachment was stored (see the values above). The property to read from an attachment or the function to call depends on the method an attachment has:

NO_ATTACHMENT

The attachment has just been created.

ATTACH_BY_VALUE

The PR_ATTACH_FILENAME and PR_ATTACH_LONG_FILENAME contains the name of the attachment. When the attachment is opened with mapi_message_openattach() the data can be read with mapi_attach_openbin().

ATTACH_EMBEDDED_MSG

The PR_DISPLAY_NAME contains the name of the attachment (This is mostly the PR_SUBJECT of the message that has been attached). With mapi_attach_openobj() the attachment can be read from the message. This function returns a message object.

ATTACH_BY_REFERENCE, ATTACH_BY_REF_RESOLVE and ATTACH_BY_REF_ONLY

These types are unsupported and should never be used.

When created, all attachment objects have an initial PR_ATTACH_METHOD value of NO_ATTACHMENT. Client applications and service providers are only required to support the attachment method represented by the ATTACH_BY_VALUE value. The other attachment methods are optional.

The message store does not enforce any consistency between the value of PR_ATTACH_METHOD and the values of the other attachment properties.


Name

Messages — Reading messages.

Messages

The reading of the contents from a message can be done in a generic way. All messages contain all types of bodies. The different body types are kept in sync automatically, and the version which is written last wins, and updates the other versions. The following body types are available:

There are 3 ways in which the body of a message can be stored:

RTF

The content of the message is stored in the PR_RTF_COMPRESSED property.

Embedded HTML in RTF

The content of the message is stored in the PR_RTF_COMPRESSED property. This is a special type of RTF that has an embedded HTML content. This version has been depricated by normal HTML.

HTML text

The content of the message is stored in the PR_HTML property. This is normal HTML formatted text.

Plain text

The content of the body is stored in the PR_BODY property, and only contains the plain text.

The PR_RTF_COMPRESSED property can hold RTF of HTML embedded text. If you use this property, you can convert it to HTML with the mapi_rtf2html function. Therefore, this property is only usefull to detect if the original message was sent in TRF or HTML.

RTF

The RTF-text may be used when messages are stored within Outlook. RTF text can only be sent through the TNEF data in a winmail.dat attachment.

Embedded HTML in RTF

The messages that are sent in HTML will be stored as RTF in the PR_RTF_COMPRESSED property. The HTML is converted from plain HTML to Embedded HTML. With the function mapi_rtf2html this type of RTF can be converted back to HTML to be shown in a browser. The function will return false when the RTF is not of the correct type.

While this is still true, this method of reading the body is depricated. If you want the HTML version of the body, use the normal HTML property.

HTML text

The normal HTML property is stored in the PR_HTML property. This is the preferred property if you want to read the HTML body.

Plain text

The PR_BODY will contain the message body in Plain text.


Name

Recipients — Using the recipient table.

Recipients

Recipients are used to specify the receiving entities for a specific message.

The structure of a recipient array in PHP is as follows. When recipients are set, you should use mapi_createoneoff() to create the right PR_ENTRYIDs:

Example 2.7.  Recipient table

// Create array of recipients usable by the PHP MAPI functions
$recipientarray = Array(Array(PR_ENTRYID => mapi_createoneoff("John Doe", "SMTP", "john@example.com"),
                              PR_DISPLAY_NAME => "John Doe",
                              PR_ADDRTYPE => "SMTP",
                              PR_EMAIL_ADDRESS => "john@example.com"
                              PR_RECIPIENT_TYPE => MAPI_TO),
                        Array(PR_ENTRYID => mapi_createoneoff("Steve Ballmer", "SMTP", "ballmer@microsoft.com"),
                              PR_DISPLAY_NAME => "Steve Ballmer",
                              PR_ADDRTYPE => "SMTP",
                              PR_EMAIL_ADDRESS => "ballmer@microsoft.com"
                              PR_RECIPIENT_TYPE => MAPI_CC),
                        Array(PR_ENTRYID => mapi_createoneoff("ConnecTUX", "SMTP", "info@connectux.com"),
                              PR_DISPLAY_NAME => "ConnecTUX",
                              PR_ADDRTYPE => "SMTP",
                              PR_EMAIL_ADDRESS => "info@connectux.com"
                              PR_RECIPIENT_TYPE => MAPI_BCC));
		

To set or get recipients, use the mapi_message_modifyrecipients and mapi_message_getrecipienttable methods.


Chapter 3. PHP-MAPI Reference

Table of Contents

General Functions — Functions that are not directly MAPI related.
Logon Functions — This section describes the various logon functions.
Store Functions — This section describes functions which are performed on MAPI Store objects.
Folder Functions — This section describes functions which are performed on MAPI Folder objects.
Table Functions — This section describes functions which are performed on MAPI Table objects.
Rules Functions — This section describes functions which are performed on the rules table.
Message Functions — This section describes functions which are performed on MAPI Message objects.
Attachment Functions — This section describes functions which are performed on MAPI Attachment objects.
Stream Functions — This section describes functions to create streams to objects and how to use these streams.
Addressbook Functions — This section describes functions to use the addressbook for user and e-mail address lookups.
Freebusy Functions — This section describes freebusy specific functions to see the freebusy data of the users.
Zarafa specific text functions — This section describes special functions used to handle texts of a mailbody.
Zarafa specific functions — This section describes Zarafa specific functions to manage users and groups and get and set permissions on folders.

Name

General Functions — Functions that are not directly MAPI related.

Synopsis

long mapi_is_error(long $hresult);
long mapi_last_hresult();
long mapi_make_scode(long $severity,
                     long $code);

long mapi_prop_id(long $proptag);
long mapi_prop_type(long $proptag);
long mapi_prop_tag(long $proptype,
                   long $propid);

array mapi_getidsfromnames(mapimsgstore $store,
                           array $names,
                           array $guids);

array mapi_getnamesfromids(mapimsgstore $store,
                           array $proptags);

array mapi_getprops(mapiobject $obj,
                    array $properties);

boolean mapi_setprops(mapiobject $obj,
                      array $properties);

boolean mapi_copyto(mapiobject $srcobj,
                    array $excludeiids,
                    array $excludeprops,
                    mapiobject $dstobj,
                    long $flags);

boolean mapi_savechanges(mapiobj $object);
boolean mapi_deleteprops(mapiobject $obj,
                         array $properties);

string mapi_openproperty(mapipropObj $mapipropObj,
                         long $propertytag,
                         string $interface,
                         long $interfaceflags,
                         long $flags);

string mapi_createoneoff(string $displayname,
                         string $type,
                         string $emailaddress,
                         long $flags);

array mapi_parseoneoff(string $oneoff);

Details

mapi_is_error ()

long mapi_is_error(long $hresult)

Checks if the high bit of the passed error is set.

$hresult
The error value to check
Returns
Returns TRUE if the specified value has the high bit set (0x80000000), indicating a error.

Example 3.1. Checking an error

if (mapi_is_error(mapi_last_hresult())) {
	echo "error!\n";
}
		

mapi_last_hresult ()

long mapi_last_hresult()

Returns 0 if last call succeeded. Otherwise, this value contains the MAPI error code. MAPI error codes are defined in include/php/mapicode.php.

Returns
the last occurred HRESULT from a MAPI function.

Example 3.2. Checking the last MAPI HRESULT

$inbox = mapi_msgstore_getreceivefolder($store);
if($inbox == false) {
	if (mapi_last_hresult() == MAPI_E_NO_ACCESS) {
		print "Access was denied to the inbox!\n";
	}
}
		

mapi_make_scode ()

long mapi_make_scode(long $severity, long $code)

This function returns the SCODE value of the specified error. Refer to MSDN for further information on SCODEs.

$severity
The severity value, 0 or 1.
$code
The actual error value

Example 3.3. Creating an SCODE error value

$error_not_found = mapi_make_scode(1, 0x010f);
		

mapi_prop_id ()

long mapi_prop_id(long $proptag)

Returns the ID part of the property tag (the high 16 bits).

$proptag
The propertytag

Example 3.4. Getting the ID of a propertytag

// Get the ID
$id = mapi_prop_id(PR_SUBJECT);	// $id is now 0x0037
		

mapi_prop_type ()

long mapi_prop_type(long $proptag)

Returns the type part of the property tag (the low 16 bits).

$proptag
The propertytag

Example 3.5. Getting the type of a propertytag

// Get the type
$id = mapi_prop_type(PR_SUBJECT);	// $id is now equal to PT_STRING8
		

mapi_prop_tag ()

long mapi_prop_tag(long $proptype, long $propid)

A propertytag is a unique identifier of a property. The property ID and property type are stores into the propertytag. Returns the property tag.

The default MAPI function is used.

[Note]Note

Because PHP can't handle unsigned longs some of the propertytags look like this -2129461248.

$proptype
The type of the propertytag that must be made. Should be one of the PT_* constants.
$propid
The unique ID for the propertytag.

Example 3.6. Making a PR_SUBJECT

// Make a PR_SUBJECT
define('PR_SUBJECT', mapi_prop_tag(PT_STRING8,   0x0037));
		

mapi_getidsfromnames ()

array mapi_getidsfromnames(mapimsgstore $store, array $names, array $guids)

Returns an array of mapped properties for the names specified. If $guids is not specified, then the default GUID {00062002-0000-0000-C000-000000000046} is used for all names. The returned properties are all of type PT_UNSPECIFIED so they have to be converted to the correct property types before being passed to mapi_setprops or mapi_getprops. Returns an array on success, FALSE on failure.

$store
The store that the ID's are being requested for
$names
The names being requested.
$guids (Optional)
The guids of the names being requested

Example 3.7. Mapping start and end named properties for calendar items

// Get the ID's of the named properties for 'Start' and 'End' of calendar items
$ids = mapi_getidsfromnames($store, Array(0x820d, 0x820e), Array("{00062002-0000-0000-C000-000000000046}","{00062002-0000-0000-C000-000000000046}"});

// Create actual proptags by adding the type of the properties
$ids[0] = mapi_prop_tag(PT_SYSTIME, mapi_prop_id($ids[0]);
$ids[1] = mapi_prop_tag(PT_SYSTIME, mapi_prop_id($ids[1]);

$startend = mapi_message_getprops($message, $ids);
		

mapi_getnamesfromids ()

array mapi_getnamesfromids(mapimsgstore $store, array $proptags)

Returns an array of mapped properties for the ids specified. Returns an array on success, FALSE on failure. The array contains a name or id and a guid for each found property.

$store
The store that the ID's are being requested for
$proptags
a list of named proptags for which names should be looked up. The prop_type is not important, and is mostly PT_NULL.

Example 3.8. Get names from IDs

// Get the ID's of the named properties for 'Start' and 'End' of calendar items
$ids = mapi_getidsfromnames($store, Array(0x820d, 0x820e));
// Re-read the names from the ids we just got.
$names = mapi_getnamesfromids($store, $ids);
print_r($names);

// or create a new array list of ids
$names = mapi_getnamesfromids($store, array(mapi_prop_tag(PT_NULL, 0x8503), mapi_prop_tag(PT_NULL, 0x8001)));
print_r($names);
		

Output:

Array
(
    [-2146631680] => Array
        (
            [guid] => guid...
            [id] => 33293
        )

    [-2146566144] => Array
        (
            [guid] => guid...
            [id] => 33294
        )

    [-2146959360] => Array
        (
            [guid] => guid...
            [id] => 33288
        )

    [-2146238464] => Array
        (
            [guid] => guid...
            [id] => 33299
        )

    [-2144010240] => Array
        (
            [guid] => guid...
            [id] => 33333
        )

)
Array
(
    [-2063400959] => Array
        (
            [guid] => guid...
            [name] => ...
        )

    [-2147418111] => Array
        (
            [guid] => guid...
            [id] => 33281
        )

)
		

mapi_getprops ()

array mapi_getprops(mapiobject $obj, array $properties)

This function returns an associative array of the requested properties and their values. If the value is not available, the value is not added to the associative array. Returns an array on success, FALSE on failure.

$obj
The object which you are requesting the properties of.
$properties (optional)
The properties that you want to read from the object.

Example 3.9. Getting the properties of a store

// Get the properties of the message store
$storeprops = mapi_getprops($userstore, array(PR_DISPLAY_NAME));

print "Store: " . $storeprops[PR_DISPLAY_NAME];
		

mapi_setprops ()

boolean mapi_setprops(mapiobject $obj, array $properties)

This function will set the properties for a MAPI object. It will work for all objects that inherit from IMAPIProp.

$obj
The object you want to set the properties of.
$properties
Array of properties you want to set.

Example 3.10. Setting the properties of a message

// Create a message and set some props.
$message = mapi_message_createmessage($inbox);

// Create an array with some props
$props = Array(PR_SUBJECT => "Testsubject",
PR_BODY => "Hello world!");

// Set props
mapi_setprops($message, $props);

// Save changes
mapi_savechanges($message);
		

mapi_copyto ()

boolean mapi_copyto(mapiobject $srcobj, array $excludeiids, array $excludeprops, mapiobject $dstobj, long $flags)

This function will copy the properties for a MAPI object. It will work for all objects that inherit from IMAPIProp.

$srcobj
The object you want to copy the properties of.
$excludeiids
Array of interface identifiers (IIDs) indicating interfaces that should not be used.
$excludeprops
Array of property tags that should be excluded.
$dstobj
The object you want to copy the properties to.
$flags
The MAPI flags to use copying. Most useful flags are MAPI_MOVE and MAPI_NOREPLACE.

Example 3.11. Copying the properties of a message

// Create a message
$newmessage = mapi_message_createmessage($inbox);

// Copy message
mapi_copyto($message, array(), array(), $newmessage);

// Save changes
mapi_savechanges($newmessage);
		

mapi_savechanges ()

boolean mapi_savechanges(mapiobj $object)

Save changes on a MAPI Object. This is mostly used on a message or attachment to push the property changes to the server.

Changes to a MAPI resource are not actually sent to the server until a mapi_savechanges is called. When creating new messages, the message wil be deleted if a mapi_savechanges call is not sent to the newly created message object. Returns TRUE on success, FALSE on failure.

$object
The object you wish to save. Can be a message, attachment, folder or store.

Example 3.12. Saving changes to a message

// Set the subject
mapi_setprops($message, Array(PR_SUBJECT) => "New subject"));
mapi_savechanges($message);
		

mapi_deleteprops ()

boolean mapi_deleteprops(mapiobject $obj, array $properties)

Delete properties from a mapi object.

This function deletes the properties given from a object. This works for all object that are derived from IMAPIProp.

Returns true when the deletion has been successful or false when something got wrong.

$obj
The object which you are deleting the properties of.
$properties (optional)
The properties that you want to delete from the object.

Example 3.13. Deleting a property of a message

// Deleting a property of a message
$message = mapi_msgstore_openentry($userstore, $message_entryid);

// remove subject from a message
mapi_deleteprops($message, array(PR_SUBJECT));
mapi_savechanges($message);
		

mapi_openproperty ()

string mapi_openproperty(mapipropObj $mapipropObj, long $propertytag, string $interface, long $interfaceflags, long $flags)

Opens a property from an object.

Some properties are not shown when a mapi_getprops is executed, and return MAPI_E_NOT_ENOUGH_MEMORY. With mapi_openproperty these properties can be read, and are returned as a string. Returns a string on success, FALSE on failure.

$mapipropObj
The object from which the property should be opened, this object can be one of the following (Mapimessage, Mapifolder, Mapiattachment, Messagestore)
$propertytag
The specific tag that should be opened.
$interface
The interface that should be used to open the property. This is normally any of the IID_I* interface definitions that are available.
$interfaceflags
Flags that should be passed to the interface which are specific to that interface. For example, you could specify STGM_TRANSACTED when opening an IID_IStream interface. Normally just 0.
$flags
The MAPI flags to use when opening this property. Most useful flags are MAPI_CREATE and MAPI_MODIFY, which must both be specified (ORed together) when creating a new property using mapi_openproperty.

Example 3.14. Getting a property

// Open a property from a folder
$viewliststream = mapi_openproperty($inbox, PR_FOLDER_VIEWLIST, IID_IStream, 0, 0);
		

mapi_createoneoff ()

string mapi_createoneoff(string $displayname, string $type, string $emailaddress, long $flags)

Creates a One-Off entry identifier.

This function creates a One-Off entry identifier. These are used in recipient tables (for PR_ENTRYID) and in message properties. These are also used in flatentrylists. Returned is a binary string with the entry identifier.

$displayname
The display name of the recipient to create a One-Off entryid for.
$type
The type of the recipient's address (mostly "SMTP").
$emailaddress
The e-mail address of the recipient.
$flags (optional)

Bitmask of flags that affects the one-off recipient.

MAPI_UNICODE

The display name, address type, and address are in Unicode format.

MAPI_SEND_NO_RICH_INFO

The recipient cannot handle formatted message content. If MAPI_SEND_NO_RICH_INFO is set, MAPI sets the recipient's PR_SEND_RICH_INFO property to FALSE. If MAPI_SEND_NO_RICH_INFO is not set, MAPI sets this property to TRUE unless the recipient's messaging address pointed to by lpszAddress is interpreted to be an Internet address. In this case, MAPI sets PR_SEND_RICH_INFO to FALSE.

Example 3.15. Creating a one-off entry identifier

// Creating a one-off entry identifier
$oneoffentryid = mapi_createoneoff("John Doe", "SMTP", "john@example.com");
		

mapi_parseoneoff ()

array mapi_parseoneoff(string $oneoff)

Parses a one-off entryid to an array with meaningful values.

This function takes a one-off entryid and parses it. Given back is an array with indexes 'name', 'type' and 'value'.

$oneoff
The input string with the one-off entryid to parse.

Example 3.16. Listing the Zarafa users

$props = mapi_getprops($message, Array(PR_ENTRYID));
$result = mapi_parseoneoff($props[PR_ENTRYID]);

echo "Display name: ".$result['name'];
echo "Type: ".$result['type'];
echo "E-mail address: ".$result['address'];
		


Name

Logon Functions — This section describes the various logon functions.

Synopsis

mapisession mapi_logon(string $profile,
                       string $password);

mapisession mapi_logon_zarafa(string $username,
                              string $password,
                              string $server);

mapisession mapi_logon_pst(string $filename);
mapimsgstore mapi_openmsgstore(mapisession $session,
                               string $entryID);

resource mapi_openentry(mapisession $session,
                        string $entryID,
                        long $flags);

mapitable mapi_getmsgstorestable(mapisession $session);
array mapi_openmsgstore_zarafa(string $username,
                               string $password,
                               string $server);

mapimsgstore mapi_openmsgstore_zarafa_other(string $entryid,
                                            string $username,
                                            string $password,
                                            string $server);

Details

mapi_logon ()

mapisession mapi_logon(string $profile, string $password)

Logon to a MAPI profile

mapi_logon uses the MAPI calls MAPILogonEx(). Returns a mapisession object on success, FALSE on failure.

$profile
The profile name to log on to. Profiles must be pre-created to be used. If $profile is empty, the default profile is used.
$password
The password to open the profile. Note: this is not the password to open a specific store or folder, just the password on the actual profile.

Example 3.17. Logging on to the default profile

// Log on to the default profile with no password
$session = mapi_logon('','');
		

mapi_logon_zarafa ()

mapisession mapi_logon_zarafa(string $username, string $password, string $server)

Logon to a Zarafa server

mapi_logon_zarafa logs a user on to the server. A MAPI Session object is returned, which is required for further calls. This is the preferred method to logon to Zarafa. On failure, FALSE is returned.

$username
The name of the user to log with.
$password
The password of the user.
$server (optional)
The location of the server. If not given, this will default to 'http://localhost:236/zarafa'. To connect over the unix socket (fastest method), use 'file:///var/run/zarafa' here.

Example 3.18. Logging on to the Zarafa server using the unix socket

$session = mapi_logon_zarafa('user','password','file:///var/run/zarafa');
if ($session == false) {
	print "logon failed with error ".mapi_last_hresult()."\n";
}
			

mapi_logon_pst ()

mapisession mapi_logon_pst(string $filename)

Logon to a local MAPI PST-file

mapi_logon_pst makes a profile and uses the filename to store the information in a PST-file. You can open a specific PST file with this function, however, remember that only one process at a time can access a PST file. However, because the php-mapi extension shares sessions accross requests, you can open the same PST file across multiple PHP requests. Returns a mapisession object on success, FALSE on failure.

$filename
The name of the PST-file to be used. When the file does not exist MAPI will create one.

Example 3.19. Logging on to a PST-file

// Log on to a PST files
$session = mapi_logon_pst('C:\outlook.pst');
			

mapi_openmsgstore ()

mapimsgstore mapi_openmsgstore(mapisession $session, string $entryID)

Opens a messagestore

The session is used to open a messagestore with the entryID given. Returns a mapimsgstore object on success, FALSE on failure.

[Note]Note

When the entryid is a hexadecimal string, the function hex2bin must be used to convert the string to binary. Also the function bin2hex can be used to convert from binary to hexadecimal.

$session
The session that is opened before.
$entryID
The unique identifier that is used to identify the messagestore.

Example 3.20. Opening the stores of a Zarafa session

// $serverlocation is optional, default http://localhost:236/zarafa
$session = mapi_logon_zarafa($username, $password, $serverlocation);
$stores = mapi_getmsgstorestable($session);
$storeslist = mapi_table_queryallrows($stores);
$userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);
$publicstore = mapi_openmsgstore($session, $storeslist[1][PR_ENTRYID]);
			

mapi_openentry ()

resource mapi_openentry(mapisession $session, string $entryID, long $flags)

Opens an entry from a messagestore or addressbook.

This function works as mapi_msgstore_openentry but automatically detects from which store the message should be opened. It can also be used for EntryIDs in the addressbook and one-off EntryIDs. Because this function must open a store to get the item in that store, it is more efficient to use the mapi_msgstore_openentry function.

$session
The session that is opened before.
$entryID
A unique identifier that is used to identify an item.
$flags
Usually 0, can be: MAPI_MODIFY (?).

mapi_getmsgstorestable ()

mapitable mapi_getmsgstorestable(mapisession $session)

Gets a table with the messagestores within the session.

Gets a table with the messagestores defined in the profile. The profile should be opened first with the function mapi_logon_zarafa. The table can be read with a mapi_table_* functions. Internally, this function calls the MAPI function GetMsgStoreTable(). Returns a mapitable object on success, FALSE on failure.

$session
The opened session

Example 3.21. Getting the table with the stores

// Get the table
$session = mapi_logon_zarafa($username, $password, $serverlocation);
$table = mapi_getmsgstorestable($session);
		  

mapi_openmsgstore_zarafa ()

array mapi_openmsgstore_zarafa(string $username, string $password, string $server)

Opens an store for an existing Zarafa user.

Opens a store of a user on the Zarafa server. The result is either false, or an array of valid php resource id's which point to the userstore and the public store.

[Warning]Warning

This function is depricated. Please use the mapi_logon_zarafa() function. This function will be removed in the future.

$username
The username of the store that needs to be opened.
$password
The password of the user that corresponds to the store.
$server (optional)
This value defaults to 'http://localhost:236/zarafa'.

Example 3.22. Opening a Zarafa message store

$stores = mapi_openmsgstore_zarafa("user","password");
// print properties of the userstore
print_r(mapi_getprops($stores[0]));
		  

mapi_openmsgstore_zarafa_other ()

mapimsgstore mapi_openmsgstore_zarafa_other(string $entryid, string $username, string $password, string $server)

Opens an store for an existing Zarafa user. This function is depricated, and will be removed in the future.

Opens a store of a different user on the Zarafa server than which is known with username and password combination. This is actually a hack at the moment because of the limitations of mapi4linux (see source for more documentation). The result is either false, or a valid php resource id.

[Warning]Warning

This function is depricated and will be removed in the future.

$username
The username of the store that needs to be opened.
$username
The username as whom we would like to open the store of another user as. Read/write rights apply from this user.
$password
The password of the user that corresponds to the username parameter.
$server (optional)
This value defaults to 'http://localhost:236/zarafa'.

Example 3.23. Opening multiple Zarafa message stores

// usage example of depricated mapi_openmsgstore_zarafa_other();
$store = mapi_openmsgstore_zarafa("user","password");
$user2_entryid = mapi_msgstore_createentryid($store, "user2");
$user2_store = mapi_openmsgstore_zarafa_other($user2_entryid, "user", "password");
print_r(mapi_getprops($user2_store));
		  

Example 3.24. Opening multiple Zarafa message stores

// normal MAPI way of opening other users store
$session = mapi_logon_zarafa($username, $password, $serverlocation);
$stores = mapi_getmsgstorestable($session);
$storeslist = mapi_table_queryallrows($stores);
$userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);
$publicstore = mapi_openmsgstore($session, $storeslist[1][PR_ENTRYID]);

$user2_entryid = mapi_msgstore_createentryid($userstore, "user2");
$user2_store = mapi_openmsgstore($session, $user2_entryid);
		  


Name

Store Functions — This section describes functions which are performed on MAPI Store objects.

Synopsis

mapifolder mapi_msgstore_getreceivefolder(mapimsgstore $store);
resource mapi_msgstore_openentry(mapimsgstore $messagestore,
                                 string $entryID,
                                 long $flags);

string mapi_msgstore_createentryid(resource $store,
                                   string $username);

mapitable mapi_msgstore_openmultistoretable(mapimsgstore $store,
                                            array $entryids,
                                            long $flags);

Details

mapi_msgstore_getreceivefolder ()

mapifolder mapi_msgstore_getreceivefolder(mapimsgstore $store)

Open the inbox for the specified store.

This function requests the EntryID for the inbox of the given store and opens the folder. Returns a mapifolder object on success, FALSE on failure.

$store
The store of which the inbox is required.

Example 3.25. Opening the inbox of a store

// Open the inbox for a user
$store = mapi_logon_zarafa($username, $password, $serverlocation);
$stores = mapi_getmsgstorestable($session);
$storeslist = mapi_table_queryallrows($stores);
$userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);
$inbox = mapi_msgstore_getreceivefolder($userstore);
		

mapi_msgstore_openentry ()

resource mapi_msgstore_openentry(mapimsgstore $messagestore, string $entryID, long $flags

Opens an entry from the messagestore.

This function opens an entry from the messagestore. The function will return a mapifolder or a mapimessage, depending on the entryID. Returns a mapimessage or mapifolder object on success, FALSE on failure.

$messagestore
The current messagestore used.
$flags (optional)

Bitmask of flags that controls how information is returned in the table. The following flags can be set:

MAPI_BEST_ACCESS

Requests that the object be opened with the maximum network permissions allowed for the user and the maximum client application access. For example, if the client has read/write access, the object should be opened with read/write access; if the client has read-only access, the object should be opened with read-only access.

MAPI_MODIFY

Requests read/write access. By default, objects are opened with read-only access, and clients should not work on the assumption that read/write access has been granted.

SHOW_SOFT_DELETES

Open a Soft Deleted Message or Folder.

Example 3.26. Opening an entry from a messagestore

// Open a folder from a store
$folder = mapi_msgstore_openentry($store, $folder_entryid);

// Open a message from a store
$message = mapi_msgstore_openentry($store, $message_entryid);
		

mapi_msgstore_createentryid ()

string mapi_msgstore_createentryid(resource $store, string $username)

Returns an entryid string to an arbitrary user store which exists on the Zarafa server.

Creates an EntryID to use with mapi_openmsgstore() function. Result is false if the store was not found, otherwise it will return a valid entryid.

$store
The store of the currently logged in user, which was opened with mapi_openmsgstore().
$username
The username of the store that needs to be opened.

Example 3.27. Opening a Zarafa message store

$user2_entryid = mapi_msgstore_createentryid($userstore, "user2");
$user2_store = mapi_openmsgstore($session, $user2_entryid);
		

mapi_msgstore_openmultistoretable ()

mapitable mapi_msgstore_openmultistoretable(mapimsgstore $store, array $entryids, long $flags

Open a special table that may contain items from different stores. The items you wish the table to contain is passed to this function.

This function opens a special table which contains items the user sets. The return value can be treated a normal table, using the mapi_table_* functions to handle it.. Returns a mapitable object on success, FALSE on failure.

$store
The store of which the inbox is required.
$entryids
An array of message entry id's. This array may contain entry id's from any store.
$flags (optional)
Flags which is currently unsused, and is 0 by default. You do not need to pass this parameter.

Example 3.28. Opening the special multistore table

// Open the inbox for a user
$store = mapi_logon_zarafa($username, $password, $serverlocation);
$stores = mapi_getmsgstorestable($session);
$storeslist = mapi_table_queryallrows($stores);
$userstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);
// array() should be replaced with an array of entry id's of messages
$mst = mapi_msgstore_openmultistoretable($userstore, array());
		


Name

Folder Functions — This section describes functions which are performed on MAPI Folder objects.

Synopsis

mapitable mapi_folder_gethierarchytable(mapifolder $folder,
                                        long $flags);

mapitable mapi_folder_getcontentstable(mapifolder $folder,
                                       long $flags);

mapimessage mapi_folder_createmessage(mapifolder $folder,
                                      long $flags);

boolean mapi_folder_deletemessages(mapifolder $folder,
                                   array $entryids,
                                   long $flags);

boolean mapi_folder_copymessages(mapifolder $srcFolder,
                                 array $messageArray,
                                 mapifolder $destFolder,
                                 long $Flags);

boolean mapi_folder_emptyfolder(mapifolder $folder,
                                long $flags);

boolean mapi_folder_copyfolder(mapifolder $srcfolder,
                               string $entryid,
                               mapifolder $destfolder,
                               string $new_foldername,
                               long $flags);

boolean mapi_folder_deletefolder(mapifolder $srcfolder,
                                 long $entryid,
                                 long $flags);

boolean mapi_folder_createfolder(mapifolder $parentfolder,
                                 string $name,
                                 string $description,
                                 long $flags,
                                 long $foldertype);

boolean mapi_folder_setreadflags(mapifolder $folder,
                                 array $entryids,
                                 long $flags);

resource mapi_folder_openmodifytable(mapifolder $inbox);
bool mapi_folder_setsearchcriteria(mapifolder $folder,
                                   array $restriction,
                                   array $folderlistr,
                                   long $flags);

bool mapi_folder_getsearchcriteria(mapifolder $folder,
                                   long $flags);

Details

mapi_folder_gethierarchytable ()

mapitable	mapi_folder_gethierarchytable(mapifolder $folder, long $flags)

Gets the hierarchytable

Opens the hierarchytable of the folder. The hierarchytable contains the subfolders of the folder. Returns a mapitable object on success, FALSE on failure.

$folder
The folder from which the hierarchytable should be opened.
$flags (optional)

Bitmask of flags that controls how information is returned in the table. The following flags can be set:

SHOW_SOFT_DELETES

Get a list of Soft Deleted Folders of the subfolder pointed to by $entryid.

Example 3.29. Getting the hierarchytable

// Get a the messagestore $inbox is a valid MAPI Folder
$table = mapi_folder_gethierarchytable($inbox);
		

mapi_folder_getcontentstable ()

mapitable	mapi_folder_getcontentstable(mapifolder $folder, long $flags)

Gets the contentstable

Opens the contentstable of the folder. The contentstable contains the messages of the folder. Returns a mapitable object on success, FALSE on failure.

$folder
The folder from which the contentstable should be opened.
$flags (optional)

Bitmask of flags that controls how information is returned in the table. The following flags can be set:

MAPI_ASSOCIATED

Get a list of associated messages of the subfolder pointed to by $folder.

SHOW_SOFT_DELETES

Get a list of Soft Deleted messages of the subfolder pointed to by $folder.

Example 3.30. Getting the getcontentstable

// Get the messages of $inbox
$table = mapi_folder_getcontentstable($inbox);
		

mapi_folder_createmessage ()

mapimessage mapi_folder_createmessage(mapifolder $folder, long $flags)

Creates a new message in the folder

This function makes a new message in the folder. It returns the newly created message and with mapi_setprops properties can be stored into the message. The message is not visible to other users until the mapi_savechanges function is called. Returns a mapimessage object on success, FALSE on failure.

$folder
The folder from in which the message should be created.
$flags (optional)

A bitmask of flags that control the creation of a folder. The following flags can be set:

MAPI_DEFERRED_ERRORS

Allows CreateMessage to return successfully, possibly before the new folder is fully accessible to the calling client. If the new message is not accessible, making a subsequent call to it can result in an error.

MAPI_ASSOCIATED

The message to be created should be included in the associated contents table rather than the standard contents table. Associated messages typically contain invisible data, such as view descriptors.

Example 3.31. Creating a new message

// Create a new message into the inbox
$viewlist = mapi_folder_createmessage($inbox);
		

mapi_folder_deletemessages ()

boolean mapi_folder_deletemessages(mapifolder $folder, array $entryids, long $flags)

Deletes messages from a folder

This function removes a message with the given entryid's from the specified folder. Note that normally in Outlook, messages are simply moved to the 'Deleted items' folder when a 'delete' is requested, and messages are only really deleted when they are removed from the 'Deleted items' folder. Returns TRUE for success, FALSE for failure.

$folder
The folder containing the messages to be deleted
$entryids
An array of binary entryID's to be removed from the folder
$flags (optional)

Bitmask of flags that controls how information is returned in the table. The following flags can be set:

DELETE_HARD_DELETE

Hard Delete the messages given by $entryid.

Example 3.32. Creating and removing a message

// Create a new message into the inbox
$msg = mapi_folder_createmessage($inbox);
mapi_savechanges($msg);

// Get the EntryID
$props = mapi_message_getprops($msg);

// Remove it
mapi_folder_deletemessages(array($props[PR_ENTRYID]));
		

mapi_folder_copymessages ()

boolean mapi_folder_copymessages(mapifolder $srcFolder, array $messageArray,  mapifolder $destFolder, long $Flags)

Copies one or more messages from one folder to another.

This function moves or copies the one or more messages given with the messageArray. The function will return true when the copying was succesfull.

The messagearray must be in following structure:

$messageArray = array (
	[0] => {entryid}
	[1] => {entryid}
	...
);
	  

The optional flag can be MESSAGE_MOVE when the messages must be moved from the sourcefolder to the destination folder, when no flag is provided the messages will be copied.

$srcfolder
The folder which you want to copy the messages from.
$messageArray
An array with the entryid's from the message you want to copy.
$destfolder
The folder which you want to copy the messages to.
$flags (optional)
Some flags you can set. (Only MESSAGE_MOVE will work)

See Also

Example 3.33. Moving messages to the wastebasket

$storeprops = mapi_msgstore_getprops($userstore);
$wastebasket = mapi_msgstore_openentry($userstore, $storeprops[PR_IPM_WASTEBASKET_ENTRYID]);

$inbox = mapi_msgstore_getreceivefolder($userstore);
$contentstable = mapi_folder_getcontentstable($inbox);
$contents = mapi_table_queryallrows($contentstable); 

foreach($contents as $row) {
	$msg[] = $row[PR_ENTRYID];
}

mapi_folder_copymessages($inbox, $msg, $wastebasket, MESSAGE_MOVE);
		

mapi_folder_emptyfolder ()

boolean mapi_folder_emptyfolder(mapifolder $folder, long $flags)

Deletes all the messages in a folder.

This function deletes all the messages and subfolders in the folder. But without deleting itself.

The followin flag can be set: DEL_ASSOCIATED With this flag set the function deletes all subfolders, including subfolders containing messages with associated content. The DEL_ASSOCIATED flag only has meaning for the top-level folder the call acts on.

$folder
The folder which you want to copy the messages from.
$flags (optional)

Bitmask of flags that controls how the folder is emptied. The following flags can be set:

DEL_ASSOCIATED

Deletes all subfolders, including subfolders containing messages with associated content. The DEL_ASSOCIATED flag only has meaning for the top-level folder the call acts on.

DELETE_HARD_DELETE

Hard Delete the messages and/or folders

See Also

Example 3.34. Emptying a folder

$storeprops = mapi_msgstore_getprops($userstore);
$wastebasket = mapi_msgstore_openentry($userstore, $storeprops[PR_IPM_WASTEBASKET_ENTRYID]);

mapi_folder_emptyfolder($wastebasket);
// wastebasket is empty now. 
		

mapi_folder_copyfolder ()

boolean mapi_folder_copyfolder(mapifolder $srcfolder, string $entryid, mapifolder $destfolder, string $new_foldername, long $flags)

Copies a folder from one parent folder to another.

This function moves or copies the folder given with entryid. The function will return true when the copy/move was successful.

$srcfolder
The parent folder which you want to copy the messages from.
$entryid
An array with the entryid's from the message you want to copy.
$destfolder
The folder which you want to copy the messages to.
$new_foldername (optional)
The new foldername of the copy of the source folder in the destination folder.
$flags (optional)

A bitmask of flags that control the setting of a message's read flag. The following flags can be set:

COPY_SUBFOLDERS

All of the subfolders in the folder to be copied should also be copied. When COPY_SUBFOLDERS is not set for a copy operation, only the folder identified by $entryid is copied. With a move operation, the COPY_SUBFOLDERS behavior is the default regardless of whether the flag is set.

FOLDER_MOVE

The folder is to be moved rather than copied. If FOLDER_MOVE is not set, the folder is copied.

Example 3.35. Move a complete folder, with subtree, to a new destination

$res = mapi_folder_copyfolder($inbox, $tocopy_folder_entryid, $dest_folder, "New folder name", COPY_SUBFOLDERS | FOLDER_MOVE);
if ($res == false) {
	print "mapi_folder_copyfolder() failed.";
}
		

mapi_folder_deletefolder ()

boolean mapi_folder_deletefolder(mapifolder $srcfolder, long $entryid, long $flags)

Deletes a folder.

This function deletes the folder given with the entryid. The function will return true when the deletion was successful.

$srcfolder
The folder which you want to delete the folder from.
$entryid
The entryid of the folder you want to delete.
$flags (optional)

A bitmask of flags that control the setting of a message's read flag. The following flags can be set:

DEL_FOLDERS

All subfolders of the subfolder pointed to by $entryid should be soft deleted.

DEL_MESSAGES

All messages in the subfolder pointed to by $entryid should be soft deleted.

DELETE_HARD_DELETE

All messages in the subfolder pointed to by $entryid should be hard deleted.

Example 3.36. Deleting a folder

// Delete a folder
$result = mapi_folder_deletefolder($parent, $folderid);
		

mapi_folder_createfolder ()

boolean mapi_folder_createfolder(mapifolder $parentfolder, string $name, string $description, long $flags, long $foldertype)

Creates a folder.

This function creates a folder within the given folder; with the given name and description. It returns true on success, false on failure.

$parentfolder
The folder in which you want to create a new folder.
$name
The name of the folder to create.
$description
A description of the folder.
$flags (optional)

A bitmask of flags that control the creation of a folder. The following flags can be set:

MAPI_DEFERRED_ERRORS

Allows CreateFolder to return successfully, possibly before the new folder is fully accessible to the calling client. If the new folder is not accessible, making a subsequent call to it can result in an error.

MAPI_UNICODE

The passed-in strings are in Unicode format. If the MAPI_UNICODE flag is not set, the strings are in ANSI format.

OPEN_IF_EXISTS

Allows the method to succeed even if the folder named in the lpszFolderName parameter already exists by opening the existing folder with that name. Note that message store providers that allow sibling folders to have the same name might fail to open an existing folder if more than one exists with the supplied name.

$foldertype (optional)

Specify the type of the folder to create.

FOLDER_GENERIC

Create a generic folder.

FOLDER_SEARCH

Create a search folder.

Example 3.37. Creating a folder

// Create a folder
$result = mapi_folder_createfolder($folder, "New folder", "Description for new folder");
		

mapi_folder_setreadflags ()

boolean mapi_folder_setreadflags(mapifolder $folder, array $entryids, long $flags)

Mark a list of messages in a folder as read.

This function markes selected messages in a given folder. All the messages can be set read or unread in the folder. It returns true on success, false on failure.

$folder
The folder in which you want mark a number of messages read.
$entryids
A list of entryids of messages that are in the given folder. When this array is empty, all the messages in the folder will be marked.
$flags (optional)

A bitmask of flags that control the creation of a folder. The following flags can be set:

CLEAR_READ_FLAG

In stead of marking the messages read, the messages are marked Unread.

Example 3.38. Marking messages in a folder read

// Mark all messages read in the inbox
$result = mapi_folder_createfolder($inbox, array());
		

mapi_folder_openmodifytable ()

resource mapi_folder_openmodifytable(mapifolder $inbox)

Returns the IExchangeModifyTable interface.

The IExchangeModifyTable interface is used for the rules table. Use this interface to read and write rules which are applied on incoming e-mails.

It returns the IExchangeModifyTable on success, false on failure.

$inbox
The rules table is only available on the default delivery folder.

Example 3.39. Requesting the IExchangeModifyTable interface

// Requesting the IExchangeModifyTable interface
$inbox = mapi_msgstore_getreceivefolder($store);
$emt = mapi_folder_openmodifytable($inbox);
		

mapi_folder_setsearchcriteria ()

bool mapi_folder_setsearchcriteria(mapifolder $folder, array $restriction, array $folderlistr, long $flags)

Set/reset search criteria of a search folder.

mapi_folder_setsearchcriteria can be used to setup a search folder. Once setsearchcriteria has been successfully called, the server will start running the search. A contents table for this folder with show only those items that match the search and will be dynamically built in the background.

Note that after setsearchcriteria has been called, the contents table will not directly show all matches, but will start to build them slowly. You can see if the search is still running by calling mapi_folder_getsearchcriteria.

$folder
The folder to set the search criteria on. This must be a search folder, ie it must have been created with type FOLDER_SEARCH
$restriction
The restriction that items in the search folder must match.
$folderlist
$flags
Valid values are BACKGROUND_SEARCH, FOREGROUND_SEARCH, RECURSIVE_SEARCH, RESTART_SEARCH, SHALLOW_SEARCH and STOP_SEARCH. Background and foreground searching is currently not implemented in Zarafa.

mapi_folder_getsearchcriteria ()

bool mapi_folder_getsearchcriteria(mapifolder $folder, long $flags)

Get search criteria and status of a search folder.

mapi_folder_getsearchcriteria returns an associative array with three values: the restriction and folder list from setsearchcriteria, and a searchstate flag. These are stored respectively in the 'restriction', 'folderlist' and 'searchstate' keys in the returned associative array. The searchstate value may be any combination of SEARCH_REBUILD, SEARCH_RUNNING, SEARCH_FOREGROUND and SEARCH_RECURSIVE.

When a folder first starts the search process (after mapi_folder_setsearchcriteria), it will return SEARCH_REBUILD | SEARCH_RUNNING until the search has completed. After this, it will return SEARCH_RUNNING, until the search is restarted or stopped. If the search has stopped, neither SEARCH_REBUILD or SEARCH_RUNNING will be set.

$folder
The search folder to query.
$flags (optional)
These flags are currently unused.

Name

Table Functions — This section describes functions which are performed on MAPI Table objects.

Synopsis

array mapi_table_queryallrows(mapitable $table,
                              array $tagarray,
                              array $restriction);

array mapi_table_queryrows(mapitable $table,
                           array $tagarray,
                           long $start,
                           long $limit);

long mapi_table_getrowcount(mapitable $table);
boolean mapi_table_sort(mapitable $table,
                        array $sortcolumns);

boolean mapi_table_restrict(mapitable $table,
                            array $restriction);

Details

mapi_table_queryallrows ()

array mapi_table_queryallrows(mapitable $table, array $tagarray, array $restriction)

Queries all the rows in a table and returns a PHP Array

This function reads all the rows of a table and returns the properties specified with the second parameter. Returns an array on success, FALSE on failure. An array with properties that should be queried can be given. Also, an array with restrictions can be given as third argument.

$table
The table resource.
$tagarray (optional)
An array with the propertytags that should be returned
$restriction (optional)
An array with the restriction that should be applied before querying all rows of the table

Example 3.40. Reading the rows from a table

// Read the rows with properties PR_ENTRYID and PR_SUBJECT

// Restriction which should restrict messages smaller than or equal to 100 bytes
$restriction = Array(RES_PROPERTY,
				Array(RELOP => RELOP_LE,
					ULPROPTAG => PR_MESSAGE_SIZE,
					VALUE => array (PR_MESSAGE_SIZE => 100) ));

$array = mapi_table_queryallrows($table, array(PR_ENTRYID, PR_SUBJECT), $restriction);
		

mapi_table_queryrows ()

array mapi_table_queryrows(mapitable $table, array $tagarray, long $start, long $limit)

Queries the rows in a table and returns a PHP Array

This function reads at most $limit rows the rows of a table, starting at row $start and returns the properties specified with the second parameter. Returns the array on success, FALSE on failure.

$table
The table resource.
$tagarray (optional)
An array with the propertytags that should be returned
$start (optional)
The starting row number to read
$limit (optional)
The maximum amount of rows to read

Example 3.41. Reading the rows from a table

// Read the rows with properties PR_ENTRYID and PR_SUBJECT
$array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), 10, 10);
		

mapi_table_getrowcount ()

long mapi_table_getrowcount(mapitable $table)

Get the amount of rows in a table

Returns the total amount of rows in the table, however, the table may change while processing the rows in the table after retrieving the amount of rows, so you cannot rely on mapi_table_queryrows() to return data for a row which should have existed according to mapi_table_getrowcount(). Returns the amount of rows on success, FALSE on failure.

$table
The table resource.

Example 3.42. Getting the the rows one by one from a table

// Read the rows with properties PR_ENTRYID and PR_SUBJECT
for ($i = 0; $i < mapi_table_getrowcount($table); $i++) {
	$array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), $i, 1);
}
		

mapi_table_sort ()

boolean mapi_table_sort(mapitable $table, array $sortcolumns)

Sort the given table according to columns.

This function sets the sort order of a table to the given sorting columns. The MAPI provider may or may not actually perform the sort operation at the time of the call, but usually the actual sort is performed when the data is retrieved from the table from mapi_table_queryrows or mapi_table_queryallrows. Returns TRUE on success, FALSE on failure.

$table
The table resource.
$array_sortcolumns
An array of columns that should be sorted. A property is the key, how it should be sorted is the value. Eg. array(PR_SUBJECT => TABLE_SORT_ASCEND, PR_RECEIVED_DATE => TABLE_SORT_DESCEND). Other sort method is TABLE_SORT_COMBINE.

Example 3.43. Sorting and retrieving the rows of a table by subject

// Read the rows with properties PR_ENTRYID and PR_SUBJECT
mapi_table_sort($table, array(PR_SUBJECT => TABLE_SORT_ASCEND));

for ($i = 0; $i < mapi_table_getrowcount($table); $i++) {
	$array = mapi_table_queryrows($table, array(PR_ENTRYID, PR_SUBJECT), $i, 1);
}
		

mapi_table_restrict ()

boolean mapi_table_restrict(mapitable $table, array $restriction

Restrict the data in a table to certain rules.

This function sets a restriction on the table, narrowing the data in the table.

$table
The table resource.
$restriction
The array holding the complete restriction.

Example 3.44. Restriction on a mapitable

$restriction = array(RES_CONTENT,
	array( FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE,
		   ULPROPTAG => PR_SUBJECT,
		   VALUE => array(PR_SUBJECT=>'spam'))
);
mapi_table_restrict($table, $restriction);
// all mapi_table_queryrows() calls here after only return rows that match the restriction

// if the result was false, mapi_last_hresult() will probably be set to MAPI_E_TOO_COMPLEX

mapi_table_restrict($table, array()); // this clears the restriction
		


Name

Rules Functions — This section describes functions which are performed on the rules table.

Synopsis

array mapi_rules_gettable(resource $emt);
boolean mapi_rules_modifytable(resource $emt,
                               array $rows,
                               long $flags);

Details

mapi_rules_gettable ()

array mapi_rules_gettable(resource $emt)

Returns the rules table from an IExchangeModifyTable interface.

This function opens a table view on the rules table from the IExchangeModifyTable interface. Returns an mapi table object on success, or FALSE on failure.

$emt
The IExchangeModifyTable interface, retrieved from mapi_folder_openmodifytable().

Example 3.45. Retrieving the rules table

// Get the current rules
$emt = mapi_folder_openmodifytable($inbox);
$rtable = mapi_rules_gettable($emt);
$rules = mapi_table_queryallrows($rtable);
print_r($rules);
	  

mapi_rules_modifytable ()

boolean mapi_rules_modifytable(resource $emt, array $rows, long $flags)

Modifies the rules table using the IExchangeModifyTable interface.

This function alters the rules table with the current row set. The previous table can be cleared when the ROWLIST_REPLACE is passed in the flags parameter. Returns an TRUE on success, or FALSE on failure.

$emt
The IExchangeModifyTable interface, retrieved from mapi_folder_openmodifytable().
$rows
The rows that need to be added, modified or deleted.
$flags (optional)
Set this flag to ROWLIST_REPLACE to empty the current table before altering the table.

Example 3.46. Modifying the rules table

// Get the interface
$emt = mapi_folder_openmodifytable($inbox);

$restriction = array(RES_CONTENT,
	array( FUZZYLEVEL => FL_SUBSTRING | FL_IGNORECASE,
		   ULPROPTAG => PR_SUBJECT,
		   VALUE => array(PR_SUBJECT=>'spam'))
);
$action = array(
	array (
		'action' => OP_MOVE,
		'storeentryid' => $publicstore_entryid,
		'folderentryid' => $public_folder_entryid
	),
);
$rule = array(

	PR_RULE_ACTIONS => $action,
	PR_RULE_CONDITION => $restriction,
	PR_RULE_PROVIDER => 'RuleOrganizer',
	PR_RULE_STATE => ST_ENABLED,
	PR_RULE_NAME => 'move "spam" mails to "important" folder in the public store',
);

$rows = array( 0 => array(
		'rowflags' => ROW_ADD,
		'properties' => $rule
	)
);

$result = mapi_rules_modifytable($emt, $rows);

$rtable = mapi_rules_gettable($emt);
$rules = mapi_table_queryallrows($rtable);
print_r($rules);
	  


Name

Message Functions — This section describes functions which are performed on MAPI Message objects.

Synopsis

boolean mapi_message_setreadflag(mapimessage $message,
                                 long $flag);

mapitable mapi_message_getattachmenttable(mapimessage $message);
mapitable mapi_message_getrecipienttable(mapimessage $message);
boolean mapi_message_modifyrecipients(mapimessage $message,
                                      long $flag,
                                      array $recipients);

mapiattach mapi_message_openattach(mapimessage $message,
                                   long $attachnum);

mapiattach mapi_message_createattach(mapimessage $message);
boolean mapi_message_deleteattach(mapimessage $message,
                                  long $attachnum);

boolean mapi_message_submitmessage(mapimessage $message);

Details

mapi_message_setreadflag ()

boolean mapi_message_setreadflag(mapimessage $message, long $flag)

Sets the readflag of a specific message.

This function changes or sets the PR_MESSAGE_FLAGS property and controls the processing of read reports.

$message
The message you are requesting the properties of.
$flag

A bitmask of flags that control the setting of a message's read flag. The following flags can be set:

CLEAR_READ_FLAG

The MSGFLAG_READ flag should be cleared in PR_MESSAGE_FLAGS and no read report should be sent.

CLEAR_NRN_PENDING

The MSGFLAG_NRN_PENDING flag should be cleared in PR_MESSAGE_FLAGS and a nonread report should not be sent.

CLEAR_RN_PENDING

The MSGFLAG_RN_PENDING flag should be cleared in PR_MESSAGE_FLAGS and no read report should be sent.

GENERATE_RECEIPT_ONLY

A read report should be sent if one is pending, but there should be no change in the state of the MSGFLAG_READ flag.

SUPPRESS_RECEIPT

A pending read report should be canceled if a read report had been requested and this call changes the state of the message from unread to read. If this call does not change the state of the message, the message store provider can ignore this flag.

Example 3.47. Marking all messages as read in the inbox

$inbox = mapi_msgstore_getreceivefolder($userstore);
$contents = mapi_folder_getcontentstable($inbox);

// Loop through all the messages in the inbox and open them one by one,
// each time, marking the message read
for ($i = 0; $i < mapi_table_getrowcount($contents); $i++) {
	$props = mapi_table_queryrows($contents, array(PR_ENTRYID), $i, 1);
	$message = mapi_msgstore_openentry($userstore, $props[PR_ENTRYID]);
	mapi_message_setreadflag($message);
}

// Note: you should actually do this with mapi_folder_setreadflags()
		

mapi_message_getattachmenttable ()

mapitable mapi_message_getattachmenttable(mapimessage $message)

Retrieve attachment table of a message

Returns a table of the attachments of a message. This table contains information about each attachment, most notably PR_ATTACH_NUM which can be passed to mapi_message_openattach to open the attachment object. The table is automatically updated when a new attachment is added or an attachment is removed (even if the attachment table is still open). Returns a mapitable object on success, FALSE on failure.

$message
The message you are requesting the attachment table of.

Example 3.48. Opening the attachmenttable of a message

$inbox = mapi_msgstore_getreceivefolder($userstore);
$contents = mapi_folder_getcontentstable($inbox);

// Loop through all the messages in the inbox and open them one by one,
// each time retrieving their attachment table
for ($i = 0; $i < mapi_table_getrowcount($contents); $i++) {
	$props = mapi_table_queryrows($contents, array(PR_ENTRYID), $i, 1);
	$message = mapi_msgstore_openentry($store, $props[PR_ENTRYID]);
	$attachtable = mapi_message_getattachmenttable($message);
	// the attachement table can be processed with the mapi_table_* functions aswell
}
		

mapi_message_getrecipienttable ()

mapitable mapi_message_getrecipienttable(mapimessage $message

Retrieve recipient table of a message

Each message has a number of recipients (including 0). This function returns a table of recipients for the message. Each row in the table represents one recipient, usually with an e-mail adress in the PR_EMAIL_ADDRESS and 'SMTP' in the PR_ADDRTYPE. Returns a mapitable object on success, FALSE on failure.

$message
The message you are requesting the recipient table of.

Example 3.49. Opening a recipienttable

$recipienttable = mapi_message_getrecipienttable ($message);
print "Number of recipients: " . mapi_table_getrowcount($recipienttable);
		

mapi_message_modifyrecipients ()

boolean mapi_message_modifyrecipients(mapimessage $message, long $flag, array $recipients)

Add or remove recipients to a message

With this function the recipients of a message can be added, modified or deleted. With the flag the needed action is selected.

The value of the flag can be:

MODRECIP_ADD

The recipients in the recipients array are added to the recipients in the message.

MODRECIP_MODIFY

The recipients in the recipients array should replace existing recipients.

MODRECIP_REMOVE

The recipients in the recipients array should be removed from the recipient list. The PR_ROWID should be used as a index for the rows to remove.

The recipient array should be formed like the following example:

$recipient[] = array {    
	  PR_DISPLAY_NAME=>"John Doe",
	  PR_EMAIL_ADDRESS=>"jdoe@example.com",
	  PR_ADDRTYPE => "SMTP",
	  PR_RECIPIENT_TYPE=> MAPI_BCC
}
	  
$message
The message the recipients should be modified.
$flag
A flag that can be set to specify what action should be performed with the recipients.
$recipients
An array with the properties of the recipients of the message.

Example 3.50. Modifying recipients

$message = mapi_folder_createmessage($folder);

mapi_message_modifyrecipients($message, MODRECIP_ADD,
	array( array(
			PR_DISPLAY_NAME=>"Pete",
			PR_EMAIL_ADDRESS=>"pete@example.com",
			PR_ADDRTYPE => "SMTP",
			PR_RECIPIENT_TYPE=> MAPI_TO
		)
);
		

mapi_message_openattach ()

mapiattach mapi_message_openattach(mapimessage $message, long $attachnum

Open an attachment from a message

This function returns a mapiattach object by opening an existing attachment in a message. You must specify which attachment to open with the $attachnum parameter. This parameter can be retrieved by looking at the attachment table retrieved with mapi_message_getattachmenttable(). Returns a mapiattach object on success, FALSE on failure.

$message
The message you are requesting the recipient table of.
$attachnum
The attachment number of the attachment you wish to open.

Example 3.51. Opening an attachment

// Open attachment number 0
$attach = mapi_message_openattach ($message, 0);

// Dump properties of the attachment (filename, etc)
print_r(mapi_attach_getprops($attach));
		

mapi_message_createattach ()

mapiattach mapi_message_createattach(mapimessage $message)

Open an attachment from a message

This function returns a mapiattach object by creating a new attachment in a message. Returns a mapiattach object on success, FALSE on failure.

$message
The message you are createing an attachment on.

Example 3.52. Creating an attachment

// Open attachment number 0
$attach = mapi_message_createattach ($message);

// Set properties of the attachment
$props = Array(PR_DISPLAY_NAME => "testname.txt",
			PR_FILENAME => "testname.txt",
			PR_ATTACH_METHOD => ATTACH_BY_VALUE,
			PR_ATTACH_DATA_BIN => "Hello world!");

mapi_setprops($attach, $props);
mapi_savechanges($attach);

// Dump properties of the attachment (filename, etc)
print_r(mapi_attach_getprops($attach));
		

mapi_message_deleteattach ()

boolean mapi_message_deleteattach(mapimessage $message, long $attachnum)

Open an attachment from a message

This function deletes an existing attachment in a message. You must specify which attachment to delete with the $attachnum parameter. This parameter can be retrieved by looking at the attachment table retrieved with mapi_message_getattachmenttable(). Returns a mapiattach object on success, FALSE on failure.

$message
The message you are deleting the attachment from.
$attachnum
The attachment number of the attachment you wish to delete.

Example 3.53. Deleting an attachment

// Delete attachment number 0
if (mapi_message_deleteattach($message, 0) == true) {
	print("successfully removed attachment");
} else {
	print("unable to remove attachment");
}
		

mapi_message_submitmessage ()

boolean mapi_message_submitmessage(mapimessage $message)

Submits a message for sending

The message is marked ready for sending when this function is called. MAPI passes messages to the underlying messaging system in the order in which they are marked for sending. Because of this functionality, a message might stay in a message store for some time before the underlying messaging system can take responsibility for it.

$message
The message you wish to submit

Example 3.54. Submitting a message

// Set the subject
mapi_setprops($message, Array(PR_SUBJECT) => "New subject"));
mapi_savechanges($message);

mapi_message_submitmessage($message);
		


Name

Attachment Functions — This section describes functions which are performed on MAPI Attachment objects.

Synopsis

string mapi_attach_openbin(mapiattach $attach,
                           long $proptag);

mapimessage mapi_attach_openobj(mapiattach $attach,
                                long $flags);

Details

mapi_attach_openbin ()

string mapi_attach_openbin(mapiattach $attach, long $proptag

Read binary contents of attachment

Retrieves the actual attachment data in the attachment when the attachment has PR_ATTACH_METHOD is 1 (ATTACH_BY_VALUE). Returns a binary string on success, FALSE on failure.

$attach
The attachment of which to retrieve binary attachment data.

Example 3.55. Getting attachment data

// Open attachment number 0
$attach = mapi_message_openattach ($message, 0);

// Output attachment data
print(mapi_attach_openbin($attach, PR_ATTACH_DATA_BIN));
	  

mapi_attach_openobj ()

mapimessage mapi_attach_openobj(mapiattach $attach, long $flags

Read message contents of attachment

Returns a message object which is embedded in an attachment. This can be done for attachment which have PR_ATTACH_METHOD 5 (ATTACH_EMBEDDED_MSG). Returns a mapimessage object on success, FALSE on failure.

$attach
The attachment of which to retrieve message attachment data.
$flags (optional)

Bitmask of flags that controls access to the property. The following flags can be set:

MAPI_CREATE

If the property does not exist, it should be created. If the property does exist, the current value of the property should be discarded. When a caller sets the MAPI_CREATE flag, it should also set the MAPI_MODIFY flag.

MAPI_MODIFY

Requests read/write access to the property. The default access is read-only. MAPI_MODIFY must be set when MAPI_CREATE is set.

Example 3.56. Getting the attachment message

// Open attachment number 0
$attach = mapi_message_openattach($message, 0);

// Open embedded message
$message = mapi_attach_openobj($attach);

// Show message contents
print_r(mapi_message_getprops($message);
	  


Name

Stream Functions — This section describes functions to create streams to objects and how to use these streams.

Synopsis

stream mapi_openpropertytostream(mapipropobj $mapiProp,
                                 ulong $propertytag,
                                 int $flags);

resource mapi_stream_create();
string mapi_stream_read(stream $stream,
                        int $lbytes);

boolean mapi_stream_seek(stream $stream,
                         int $bytes,
                         int $flags);

boolean mapi_stream_setsize(stream $stream,
                            int $newsize);

boolean mapi_stream_commit(stream $stream);
boolean mapi_stream_write(stream $stream,
                          string $data);

array mapi_stream_stat(stream $stream);

Details

mapi_openpropertytostream ()

stream mapi_openpropertytostream(mapipropobj $mapiProp, ulong $propertytag, int $flags)

Opens a property to a stream object

[Warning]Warning
(DEPRECATED: use mapi_openproperty instead)

This functions opens a stream on a specific property. It returns a stream that can be used with other stream functions to read and write the data.

$mapiProp
A resource that is derived from MAPIProp.
$propertytag
The property that should be read.
$flags (optional)

The default access is read-only. Flags you can give:

MAPI_CREATE

If the property does not exist, it should be created. If the property does exist, the current value of the property should be discarded. When a caller sets the MAPI_CREATE flag, it should also set the MAPI_MODIFY flag.

MAPI_MODIFY

Requests read/write access to the property. The default access is read-only. MAPI_MODIFY must be set when MAPI_CREATE is set.

Example 3.57. Reading a stream

$bodyStream = mapi_openpropertytostream($message, PR_BODY);

$stat = mapi_stream_stat($bodyStream)
	  

mapi_stream_create ()

resource >mapi_stream_create()

Create a new in-memory stream object

This function can be used to create an in-memory stream object. Any data written to this object can subsequently be read from the same stream with mapi_stream_read().

Example 3.58. Creating a new stream

$stream = mapi_stream_create();
mapi_stream_write($stream, "Hello, world!");
	  

mapi_stream_read ()

string mapi_stream_read(stream $stream, int $lbytes)

Reads data from a stream

This functions read a specific ammount of data from a stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$lbytes
The ammount of bytes that should be read.

Example 3.59. Reading from a stream

$body = mapi_stream_read($stream, 100);

echo $body;	// will echo the first 100 bytes of the body
	  

mapi_stream_seek ()

boolean mapi_stream_seek(stream $stream, int $bytes, int $flags)

Moves the internal pointer the given bytes.

This functions seek in a stream. It can move the pointer with the given bytes. The function will return true when the seeking was succesful or false when it wasn't. If no flag is given, STREAM_SEEK_CUR will be assumed.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$bytes
The ammount of bytes the pointer should be moved.
$flags

A flag that can be given:

STREAM_SEEK_SET

TThe new seek pointer is an offset relative to the beginning of the stream.

STREAM_SEEK_CUR

The new seek pointer is an offset relative to the current seek pointer location.

STREAM_SEEK_END

The new seek pointer is an offset relative to the end of the stream.

Example 3.60. Seeking in a stream

mapi_stream_seek($stream, 100);	// will move the pointer 100 bytes
	  

mapi_stream_setsize ()

boolean mapi_stream_setsize(stream $stream, int $newsize)

Resizes a stream

This functions resizes the stream. With this function it is possible to preallocate space to use with the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$newsize
The new size of the stream in bytes.

Example 3.61. Setting the size of a stream

mapi_stream_setsize($stream, 100);	// will resize the stream to a size of 100 bytes
	  

mapi_stream_commit ()

boolean mapi_stream_commit(stream $stream)

Commits the stream

This functions commits the stream. Now all changes are saved. Will return true when everything is oke or false when an error has occured.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()

Example 3.62. Committing a stream

mapi_stream_commit($stream);	// commit the stream, all data is saved.
	  

mapi_stream_write ()

boolean mapi_stream_write(stream $stream, string $data)

Write data to a stream

This functions writes data to the stream. The pointer will also moved the places that is needed. Use mapi_stream_commit to save the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()
$data
The bytes that should be written into the stream.

Example 3.63. Writing data into a stream

mapi_stream_write($stream, "data");	// will write "data" into the stream and moves the pointer 4 bytes.
	  

mapi_stream_stat ()

array mapi_stream_stat(stream $stream)

Gets the statistics of the stream.

This functions reads the statistics from a stream and returns this in an assoc array. For now only the element 'cb' is supported, this gives the size of the stream.

$stream
A resource that contains the stream. This resource is given back by mapi_openproperty()

Example 3.64. Getting the statistics from a stream

$stat = mapi_stream_stat($stream);

echo "Size :" . $stat['cb'];
// will read the stats from the stream.
	  


Name

Addressbook Functions — This section describes functions to use the addressbook for user and e-mail address lookups.

Synopsis

resource mapi_openaddressbook(mapisession $session);
resource mapi_ab_openentry(resource $addrbook,
                           string $entryid,
                           long $flags);

array mapi_ab_resolvename(resource $addrbook,
                          array $name_entry);

string mapi_ab_getdefaultdir(resource $addrbook);

Details

mapi_openaddressbook ()

resource mapi_openaddressbook(mapisession $session)

Opens the MAPI Addressbook. On Zarafa, this only is the Global Addressbook, containing the Zarafa users.

This function will return a MAPI Addressbook resource when successfull, or FALSE on failure.

$session
The MAPI Session that is opened before.

Example 3.65. Open the Addressbook

// First, logon to zarafa to get a session
$session = mapi_logon_zarafa($username, $password, $server);

// Now we can open the addressbook
$addrbook = mapi_openaddressbook($session);
		

mapi_ab_openentry ()

resource mapi_ab_openentry(resource $addrbook, string $entryid, long $flags)

Calls the OpenEntry() function on the Addressbook object.

This function performs the OpenEntry() call on the AddressBook interface. Returns FALSE on failure, otherwise an MailUser, DistList or ABContainer is returned as resource.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().
$entryid (optional)
This is the EntryID to request from the Addressbook. This can result in opening a MailUser, DistList or an Addressbook Container, which will be returned. When the EntryID is NULL, the top-level Addressbook Container is returned.
$flags (optional)
MAPI_BEST_ACCESS (default), MAPI_DEFERRED_ERRORS and/or MAPI_MODIFY.

Example 3.66. Requesting the top-level AddressBook container

$addrbook = mapi_openaddressbook($session);
$abcontainer = mapi_ab_openentry($addrbook);
		

mapi_ab_resolvename ()

array mapi_ab_resolvename(resource $addrbook, array $name_entry)

Calls the ResolveName() function on the Addressbook object.

This function performs the ResolveName() call on the AddressBook interface.

This function returns MAPI_E_AMBIGUOUS_RECEIP or MAPI_E_NOT_FOUND when these errors occurred, or FALSE on any other error. When the user is found, the array returned has the full information of the user requested.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().
$array
This is an array of arrays of properties, and will be converted to an AdrList structure. This structure will be used to find the given name of a user.

Example 3.67. Resolving a user to e-mail address

$addrbook = mapi_openaddressbook($session);
$user = array( array( PR_DISPLAY_NAME => 'steve' ), array( PR_DISPLAY_NAME => 'milo' ) );
$user = mapi_ab_resolvename($addrbook, $user);
print_r($user);
		

Output:

Array
(
    [0] => Array
        (
            [805437470] => SMTP
            [805371934] => Steve Hardy
            [956301315] => 0
            [805503006] => steve@connectux.com
            [268370178] => ...
            [267780354] => ...
            [268304387] => 6
            [267976962] => ...
            [806027522] => SMTP:STEVE@CONNECTUX.COM
        )

    [1] => Array
        (
            [805437470] => SMTP
            [805371934] => Milo Oostergo
            [956301315] => 0
            [805503006] => milo@connectux.com
            [268370178] => ...
            [267780354] => ...
            [268304387] => 6
            [267976962] => ...
            [806027522] => SMTP:MILO@CONNECTUX.COM
        )

)
		

mapi_ab_getdefaultdir ()

string mapi_ab_getdefaultdir(resource $addrbook)

Calls the GetDefaultDir() function on the Addressbook object.

This function performs the GetDefaultDir() call on the AddressBook interface.

This function returns an EntryID on success, FALSE on error.

$addrbook
The Addressbook resource, retrieved with mapi_openaddressbook().

Example 3.68. Opening the default Addressbook Directory

$addrbook = mapi_openaddressbook($session);
#entryid = mapi_ab_getdefaultdir($addrbook);
		


Name

Freebusy Functions — This section describes freebusy specific functions to see the freebusy data of the users.

Synopsis

resource IFreeBusySupport mapi_freebusysupport_open(resource $session,
                                                    resource $messagestore);

boolean mapi_freebusysupport_close(resource $freebusysupport);
array freebusydata mapi_freebusysupport_loaddata(resource $freebusysupport,
                                                 array $fbusers);

array freebusydata mapi_freebusysupport_loadupdate(resource $freebusysupport,
                                                   array $fbusers);

resource freebusyenumblock mapi_freebusydata_enumblocks(resource $freebusydata,
                                                        long $starttime,
                                                        long $endtime);

array mapi_freebusydata_getpublishrange(resource $freebusydata);
boolean mapi_freebusydata_setrange(resource $freebusydata,
                                   long $starttime,
                                   long $endtime);

boolean mapi_freebusyenumblock_reset(resource $freebusyenumblock);
boolean mapi_freebusyenumblock_skip(resource $freebusyenumblock);
boolean mapi_freebusyenumblock_restrict(resource $freebusyenumblock,
                                        long $starttime,
                                        long $endtime);

boolean mapi_freebusyenumblock_next(resource $freebusyenumblock,
                                    long $celt,
                                    long $endtime);

boolean mapi_freebusyupdate_reset(resource $freebusyupdate);
boolean mapi_freebusyupdate_publish(resource $freebusyupdate,
                                    array $freebusyblocks);

boolean mapi_freebusyupdate_savechanges(resource $freebusyupdate,
                                        long $starttime,
                                        long $endtime);

Details

mapi_freebusysupport_open ()

resource mapi_freebusysupport_open(resource $session, resource $messagestore)

Retreive freebusy support object

$session
The resource id of a session of the user.
$messagestore (optional)
The resource id of the messagestore of the user. Only when you update the freebusy data.

Example 3.69. Open a freebusysupport object

$fbsupport = mapi_freebusysupport_open($session);
		

resource $fbsupport, freebusysupport


mapi_freebusysupport_close ()

boolean mapi_freebusysupport_close(resource $freebusysupport)

Close the freebusy support object

$freebusysupport
The resource id of a freebusysupport object.

Example 3.70. Close a freebusysupport object

$fbsupport = mapi_freebusysupport_open($session);
// Do something
$result = mapi_freebusysupport_close($fbsupport);
		

true is succeeded


mapi_freebusysupport_loaddata ()

array mapi_freebusysupport_loaddata(resource $freebusysupport, array $fbusers)

Get a freebusydata object for one of more users.

$freebusysupport
The resource id of a freebusysupport object.
$fbusers
An array of user addressbook entryids

Example 3.71. Get freebusydata object of one user

$fbsupport = mapi_freebusysupport_open($session);

$fbDataArray = mapi_freebusysupport_loaddata($fbsupport, array($userentrid1, $userentrid2) );

if(isset($fbDataArray[0]))
{
  $rangeuser1 = mapi_freebusydata_getpublishrange($fbDataArray[0]);
  print_r($rangeuser1);
}else {
  echo "No freebusy for User 1\n";
}

if(isset($fbDataArray[1]))
{
  $rangeuser2 = mapi_freebusydata_getpublishrange($fbDataArray[1]);
  print_r($rangeuser2);
}else {
  echo "No freebusy for User 2\n";
}

mapi_freebusysupport_close($fbsupport);
		

Array( [start] => 1157061600 [end] => 1162335600 ) No freebusy for User 2


mapi_freebusysupport_loadupdate ()

Get freebusy write objects for one of more users.

array freebusydata mapi_freebusysupport_loadupdate(resource $freebusysupport,
                                                   array $fbusers);
$freebusysupport
The resource id of a freebusysupport object.
$fbusers
An array of user addressbook entryids

Example 3.72. Get freebusyupdate object of one user

$fbupdate = mapi_freebusysupport_loadupdate($fbsupport, array($userentryid));

$result = mapi_freebusyupdate_reset($fbupdate[0]);

$fbblocks = array( 
  array("start" => 1157439600, "end" => 1157468400, "status" => 2),
  array("start" => 1157526000, "end" => 1157554800, "status" => 2)
);
// Add fbblocks
$result = mapi_freebusyupdate_publish($fbupdate[0], $fbblocks);
		  
// Save data
$result = mapi_freebusyupdate_savechanges($fbupdate[0], 1157061600, 1162335600);
		

Description

Get freebusyupdate object of one or more users to write the new freebusydata.

See Also

mapi_freebusysupport_open mapi_freebusysupport_close

mapi_freebusydata_enumblocks ()

resource mapi_freebusydata_enumblocks(resource $freebusydata, long $starttime, long $endtime)

Get an interface to supports accessing and enumerating free/busy blocks of data for a user within a time range.

$freebusydata
The resource id of a freebusydata object.
$starttime
starttime of the freebusy information in unixtimestamp
$endtime
endtime of the freebusy information in unixtimestamp

Example 3.73. Get freebusy enumblock object of one user and read some data

$enumblock = mapi_freebusydata_enumblocks($fbData, 0, 0xFFFFFFFF);

// Set the cursur on the begining
$result = mapi_freebusyenumblock_reset($enumblock);
		  
//Read the free/busy blocks in a cycles of 2 blocks
while(true)
{
  $blocks = mapi_freebusyenumblock_next($enumblock, 2);
  if($blocks == false)
    break;
  print_r($blocks);
}
		

Array ( [0] => Array ( [start] => 1157439600 [end] => 1157468400 [status] => 2 ) [1] => Array ( [start] => 1157526000 [end] => 1157554800 [status] => 2 ) )


mapi_freebusydata_getpublishrange ()

Gets a preset time range for an enumeration of free/busy blocks of data for a user

Get free/busy publish range, start and end time in unixtimestamp format

array mapi_freebusydata_getpublishrange(resource $freebusydata);
$freebusydata
The resource id of a freebusydata object.

Example 3.74. Get freebusy publish range

		  See mapi_freebusysupport_loaddata
		

mapi_freebusydata_setrange ()

boolean mapi_freebusydata_setrange(resource $freebusydata, long $starttime, long $endtime)

Sets the range of time for an enumeration of free/busy block of data for a user.

Sets the freebusy range of time

$freebusydata
The resource id of a freebusydata object.
$starttime
starttime of the freebusy information in unixtimestamp
$endtime
endtime of the freebusy information in unixtimestamp

Example 3.75. Sets the freebusy range of time.

$result = mapi_freebusydata_setrange($freebusydata, 1157061600, 1162335600);
		

return $result, false or true


mapi_freebusyenumblock_reset ()

boolean mapi_freebusyenumblock_reset(resource $freebusyenumblock)

Resets the enumerator by setting the cursor to the beginning.

$freebusyenumblock
The resource id of a free/busy enumblock object.

Example 3.76. Sets the cursor to the beginning

		  See mapi_freebusydata_enumblocks
		

mapi_freebusyenumblock_skip ()

boolean mapi_freebusyenumblock_skip(resource $freebusyenumblock)

Skips a specified number of blocks of free/busy data.

$freebusyenumblock
The resource id of a free/busy enumblock object.

Example 3.77. Skips 2 blocks of free/busy data.

$enumblock = mapi_freebusydata_enumblocks($fbData, 0, 0xFFFFFFFF);

// Set the cursur on the begining
$result = mapi_freebusyenumblock_reset($enumblock);

// Skip 2 free/busy blocks
$result = mapi_freebusyenumblock_skip($enumblock, 2);

// Read the 2 free/busy blocks
$blocks = mapi_freebusyenumblock_next($enumblock, 2);
		

mapi_freebusyenumblock_restrict ()

boolean mapi_freebusyenumblock_restrict(resource $freebusyenumblock, long $starttime, long $endtime)

Restricts the enumeration to a specified time period.

$freebusyenumblock
The resource id of a free/busy enumblock object.
$starttime
starttime of the free/busy information in unixtimestamp
$endtime
endtime of the free/busy information in unixtimestamp

Example 3.78. Restricts the enumeration to a specified time period.

$enumblock = mapi_freebusydata_enumblocks($fbData, 0, 0xFFFFFFFF);

// Set the cursur on the begining
$result = mapi_freebusyenumblock_reset($enumblock);

//Restrict the free/busy data
$result = mapi_freebusyenumblock_restrict($enumblock, 0x12345578, 0xFFFF0000);

//Read the 2 free/busy blocks
$blocks = mapi_freebusyenumblock_next($enumblock, 2);
		

-


mapi_freebusyenumblock_next ()

boolean mapi_freebusyenumblock_next(resource $freebusyenumblock, long $celt, long $endtime)

Gets the next specified number of blocks of free/busy data in an enumeration.

$freebusyenumblock
The resource id of a free/busy enumblock object.
$celt
items to retreive

Example 3.79. Gets the next 10 blocks of free/busy data.

		  See mapi_freebusydata_enumblocks
		

mapi_freebusyupdate_reset ()

boolean mapi_freebusyupdate_reset(resource $freebusyupdate)

Remove all current free/busy data

$freebusysupport
The resource id of a freebusyupdate object.

Example 3.80. Remove all current free/busy data

		  See mapi_freebusysupport_loadupdate
		

mapi_freebusyupdate_publish ()

boolean mapi_freebusyupdate_publish(resource $freebusyupdate, array $freebusyblocks)

Publish a specified number of blocks of free/busy data. May be called more than once successively.

$freebusysupport
The resource id of a freebusyupdate object.
$freebusyblocks
An array of free/busy data blocks.

Example 3.81. Publish 2 blocks of free/busy data

		  See mapi_freebusysupport_loadupdate
		

mapi_freebusyupdate_savechanges ()

boolean mapi_freebusyupdate_savechanges(resource $freebusyupdate, long $starttime, long $endtime)

Save the free/busy data with time frame between the begintime and endtime.

$freebusysupport
The resource id of a freebusyupdate object.
$starttime
starttime of the freebusy information in unixtimestamp
$endtime
endtime of the freebusy information in unixtimestamp

Example 3.82. Save the free/busy data

		  See mapi_freebusysupport_loadupdate
		


Name

Zarafa specific text functions — This section describes special functions used to handle texts of a mailbody.

Synopsis

string mapi_decompressrtf(string $compressedRTF);
string mapi_rtf2html(string $RTF);
string mapi_html2rtf(string $HTML);
string mapi_compressrtf(string $uncompressedRTF);

Details

mapi_decompressrtf ()

>string mapi_decompressrtf(string $compressedRTF)

Decompresses a compressed RTF stream from the PR_RTF_COMPRESSED property.

This function will decompress the RTF Body from a message and return the decompressed RTF.

$compressedRTF
A string with the compressed RTF information. This information can be retrieved with mapi_openproperty($message, PR_RTF_COMPRESSED)

Example 3.83. Decompress a RTF body

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

echo mapi_decompressrtf($rtf); // will echo the raw rtf data
		

mapi_rtf2html ()

string mapi_rtf2html(string $RTF)

Decodes the raw RTF data to readable HTML.

This function will read the embedded HTML from an RTF stream. When the RTF Stream is not of the embedded HTML RTF type the function will return false indicating that the body must be read as plaintext.

$RTF
A string with the raw RTF data. This data is usally the output from the mapi_decompressrtf function.

Example 3.84. Decoding RTF

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

echo mapi_rtf2html(mapi_decompressrtf($rtf));	// will echo the html data.
		

mapi_html2rtf ()

string mapi_html2rtf(string $HTML)

Encodes the HTML as RTF.

This function encodes the given HTML into an RTF document, which can subsequently be passed to mapi_compressrtf to be included in MAPI messages. The HTML is encoded so that when it is decoded, the exact HTML source is again readable.

$HTML
The HTML data to be encoded into RTF.

Example 3.85. Encoding HTML

echo mapi_html2rtf("<HTML><p>This is a test</HTML>");
		

mapi_compressrtf ()

Compresses an uncompressed RTF stream for the PR_RTF_COMPRESSED property.

This function will compress the RTF Body for a message and return the compressed RTF.

string mapi_compressrtf(string $uncompressedRTF);
$uncompressedRTF
A string with the uncompressed RTF information. This information can be stored using mapi_openpropertystream($message, PR_RTF_COMPRESSED), mapi_stream_write($stream, $compressedRTF) etc.

Example 3.86. Compress an RTF body

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

$decompressedRTF = mapi_decompressrtf($rtf);
// will echo the raw rtf data, uncompressed
echo $decompressedRTF;

// will echo compressed RTF data, usable for streaming (back) to PR_RTF_COMPRESSED
echo mapi_compressrtf($decompressedRTF);
		


Name

Zarafa specific functions — This section describes Zarafa specific functions to manage users and groups and get and set permissions on folders.

Synopsis

long mapi_zarafa_createuser(store $storeid,
                            string $username,
                            string $password,
                            string $fullname,
                            string $emailaddress,
                            long $isnonactive,
                            long $isadmin);

boolean mapi_zarafa_setuser(store $store,
                            long $userid,
                            string $username,
                            string $fullname,
                            string $emailaddress,
                            string $password,
                            long $isnonactive,
                            long $isadmin);

boolean mapi_zarafa_createstore(store $storeid,
                                long $storetype,
                                long $userid);

boolean mapi_zarafa_deleteuser(resource $store,
                               string $username);

array mapi_zarafa_getuserlist(resource $messagestore,
                              int $companyid);

array mapi_zarafa_getuser_by_id(resource $messagestore,
                                int $userid);

array mapi_zarafa_getuser_by_name(resource $messagestore,
                                  string $username);

array mapi_zarafa_getgroup_by_id(resource $messagestore,
                                 int $groupid);

array mapi_zarafa_getgroup_by_name(resource $messagestore,
                                   string $group);

boolean mapi_zarafa_setgroup(resource $messagestore,
                             long $groupid,
                             string $groupname);

array mapi_zarafa_getgrouplist(resource $messagestore,
                               int $companyid);

long mapi_zarafa_creategroup(resource $messagestore,
                             string $groupname);

boolean mapi_zarafa_deletegroup(resource $messagestore,
                                string $groupname);

boolean mapi_zarafa_addgroupmember(resource $messagestore,
                                   int $groupid,
                                   int $userid);

boolean mapi_zarafa_deletegroupmember(resource $messagestore,
                                      int $groupid,
                                      int $userid);

array mapi_zarafa_getgrouplistofuser(resource $messagestore,
                                     long $userid);

array mapi_zarafa_getuserlistofgroup(resource $messagestore,
                                     long $groupid);

long mapi_zarafa_createcompany(resource $messagestore,
                               string $companyname);

boolean mapi_zarafa_deletecompany(resource $messagestore,
                                  string $companyname);

array mapi_zarafa_getcompany_by_id(resource $messagestore,
                                   int $companyid);

array mapi_zarafa_getcompany_by_name(resource $messagestore,
                                     string $company);

array mapi_zarafa_getcompanylist(resource $messagestore);
boolean mapi_zarafa_add_company_remote_viewlist(resource $messagestore,
                                                int $setcompanyid,
                                                int $companyid);

boolean mapi_zarafa_del_company_remote_viewlist(resource $messagestore,
                                                int $setcompanyid,
                                                int $companyid);

array mapi_zarafa_get_remote_viewlist(resource $messagestore,
                                      int $companyid);

boolean mapi_zarafa_add_user_remote_adminlist(resource $messagestore,
                                              int $userid,
                                              int $companyid);

boolean mapi_zarafa_del_user_remote_adminlist(resource $messagestore,
                                              int $userid,
                                              int $companyid);

array mapi_zarafa_get_remote_adminlist(resource $messagestore,
                                       int $companyid);

boolean mapi_zarafa_add_quota_recipient(resource $messagestore,
                                        int $companyid,
                                        int $recipient,
                                        int $type);

boolean mapi_zarafa_del_quota_recipient(resource $messagestore,
                                        int $companyid,
                                        int $recipientid,
                                        int $type);

array mapi_zarafa_get_quota_recipientlist(resource $messagestore,
                                          int $userid);

array mapi_zarafa_getpermissionrules(resource $mapiobject,
                                     long $acl_type);

boolean mapi_zarafa_setpermissionrules(resource $mapiobject,
                                       array $acls);

boolean mapi_inetmap_imtoinet(resource $session,
                              resource $addrbook,
                              resource $message,
                              array $flags);

Details

mapi_zarafa_createuser ()

long mapi_zarafa_createuser(store $storeid, string $username, string $password, string $fullname, string $emailaddress, long $isnonactive, long $isadmin)

Creates a new user on an Zarafa server

Creates a new user on the Zarafa server. This can only be done when a store is specified which is logged on to a server with administration rights. The user is then created, but is initially 'nonactive' after being created. If the username existed before the call to mapi_zarafa_createstore(), an error is generated. The returned value can be used in a call to mapi_zarafa_setuser to set user settings of the created user.

$store
A store that is logged on to an Zarafa server, with sufficient permissions to create users.
$username
The username of the user to be added. The user must not exist prior to calling mapi_zarafa_createuser.
$password
The login password for this user
$fullname
The full name of the user as to be displayed to human users (e.g. 'John Doe')
$emailaddress
The fully qualified e-mail address of the user (e.g. 'john.doe@domain.com')
$isnonactive (optional)
Specifies whether the account is non-active. Specify 0 here to activate an account.
$isadmin (optional)
Specifies whether the account is an administator user. Specify 0 here for a normal account, 1 for an admin account, 2 for a system admin account (This level allows the user to manage companies).

Example 3.87. Creating a user

$session = mapi_logon_zarafa($admin_user, $password, $serverlocation);

$stores = mapi_getmsgstorestable($session);
$storeslist = mapi_table_queryallrows($stores);
$adminstore = mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]);

$userid = mapi_zarafa_createuser($adminstore, "newuser", "pass", "New User Name", "new@test.com");

if($userid == false) {
	print "Error creating user\n";
}
		

mapi_zarafa_setuser ()

Sets user information for a specific user on a Zarafa server

This function sets the user information on a user previously created (with mapi_zarafa_createuser). This call can only be done by users with administration rights on the server.

boolean mapi_zarafa_setuser(store $store,
                            long $userid,
                            string $username,
                            string $fullname,
                            string $emailaddress,
                            string $password,
                            long $isnonactive,
                            long $isadmin);
$store
A store that is logged on to a Zarafa server, with sufficient permissions to create users.
$userid
The ID of the user to update
$username
The username of the user, this is the name which was used to login into the system.
$fullname
The full name of the user as to be displayed to human users (e.g. 'John Doe')
$emailaddress
The fully qualified e-mail address of the user (e.g. 'john.doe@domain.com')
$password
The login password for this user
$isnonactive
Specifies whether the account is non-active. Specify 0 here to activate an account.

Example 3.88. Setting user information

$store = mapi_openmsgstore_zarafa("user","password");

$userid = mapi_zarafa_createuser($store, "newuser", "pass", "New User Name", "new@test.com");

if($userid == false)
	print "Error creating user\n";
else
	mapi_zarafa_setuser($store, $userid, 'John Doe', 'john.doe@domain.com', 'password', 0);
		

mapi_zarafa_createstore ()

Creates a store on a Zarafa server

Creates a complete store either for a specific user or creates a public store. When creating a user store, the standard folders 'Inbox', 'Outbox', etc. are all created and added to the store.

boolean mapi_zarafa_createstore(store $storeid,
                                long $storetype,
                                long $userid);
$store
A store that is logged on to a Zarafa server, with sufficient permissions to create users.
$storetype
The type of the store. (0 = private mailbox, 1 = public store)
$userid
The user ID to which the store should be coupled if this is a private mailbox

Example 3.89. Creating a store

$store = mapi_openmsgstore_zarafa("user","password");

$userid = mapi_zarafa_createuser($store, "newuser");

if($userid == false)
	print "Error creating user\n";

mapi_zarafa_setuser($store, $userid, 'John Doe', 'john.doe@domain.com', 'password', 0);

mapi_zarafa_createstore($store, 0, $userid);
		

mapi_zarafa_deleteuser ()

Deletes a Zarafa user.

This function deletes a user from the Zarafa server. The deleted store will be moved to an Admin folder in the toplevel of the public store. true is returned on success.

boolean mapi_zarafa_deleteuser(resource $store,
                               string $username);
$store
The store resource of an admin user.
$username
The loginname of the user to delete.

Example 3.90. Deleting a user

// Deleting a user, deleting store with it.
$result = mapi_zarafa_deleteuser($store, "john");
		

mapi_zarafa_getuserlist ()

Retreive a list of Zarafa users.

Returns an associative array of all users, with the username as key, and the full name as value.

array mapi_zarafa_getuserlist(resource $messagestore,
                              int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
This companyid for which we are requesting the members of. (optional)

Example 3.91. Listing the Zarafa users

$tempStoreslist = mapi_openmsgstore_zarafa($username, "password", "http://localhost:236/zarafa");
$msgstore = $tempStoreslist[0];
$users = mapi_zarafa_getuserlist($msgstore);
print_r($users);
		

Array ( [SYSTEM] => SYSTEM User [username] => Fullname )


mapi_zarafa_getuser_by_id ()

Retreive user information for zarafa user.

Returns an associative array of information for the specified user, or FALSE of the user does not exist or an other error occurred. The associative array contains 'userid', 'username', 'fullname', 'emailaddress', 'nonactive' and 'admin'.

array mapi_zarafa_getuser_by_id(resource $messagestore,
                                int $userid);
$messagestore
The resource id of the messagestore of the logged-on user.
$userid
The id of the user whose information is te be returned

Example 3.92. Getting user information

$info = mapi_zarafa_getuser_by_id($msgstore, 10);

print $info["userid"];
print $info["username"];
print $info["fullname"];
print $info["emailaddress"];
print $info["admin"];
print $info["nonactive"];
		

mapi_zarafa_getuser_by_name ()

mapi_zarafa_getuser ()

Retreive user information for zarafa user.

Returns an associative array of information for the specified user, or FALSE of the user does not exist or an other error occurred. The associative array contains 'userid', 'username', 'fullname', 'emailaddress', 'nonactive' and 'admin'.

array mapi_zarafa_getuser_by_name(resource $messagestore,
                                  string $username);
$messagestore
The resource id of the messagestore of the logged-on user.
$username
The username of the user whose information is te be returned

Example 3.93. Getting user information

$info = mapi_zarafa_getuser($msgstore, "username");

print $info["userid"];
print $info["username"];
print $info["fullname"];
print $info["emailaddress"];
print $info["admin"];
print $info["nonactive"];
		

mapi_zarafa_getgroup_by_id ()

Retrieve group information for zarafa group.

Returns an associative array of information for the specified group, or FALSE of the group does not exist or an other error occurred. The associative array contains 'groupid' and 'groupname'.

array mapi_zarafa_getgroup_by_id(resource $messagestore,
                                 int $groupid);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupid
The id of the group whose information is te be returned

Example 3.94. Getting group information

$info = mapi_zarafa_getgroup_by_id($msgstore, 2);

print $info["groupid"];
print $info["groupname"];
		

mapi_zarafa_getgroup_by_name ()

mapi_zarafa_getgroup ()

Retrieve group information for zarafa group.

Returns an associative array of information for the specified group, or FALSE of the group does not exist or an other error occurred. The associative array contains 'groupid' and 'groupname'.

array mapi_zarafa_getgroup_by_name(resource $messagestore,
                                   string $group);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupname
The name of the group whose information is te be returned

Example 3.95. Getting group information

$info = mapi_zarafa_getgroup($msgstore, "Everyone");

print $info["groupid"];
print $info["groupname"];
		

mapi_zarafa_setgroup ()

Set group information for a specific Zarafa group.

Modifies the given group, setting the groupname. Basically, this is a 'rename' of a group, as groups currently have no other information apart from their name. Returns TRUE on success, FALSE on error.

boolean mapi_zarafa_setgroup(resource $messagestore,
                             long $groupid,
                             string $groupname);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupid
The ID of the group to be changed
$groupname
The name of the group whose information is te be returned

Example 3.96. Changing group information

mapi_zarafa_setgroup($msgstore, 5, "NewName");
		

mapi_zarafa_getgrouplist ()

Get list of all groups

Returns an array of all groups. Each list item is an associative array with the keys 'groupname' and 'groupid'. There are as many items in the returned array as there are groups that are viewable by the user

array mapi_zarafa_getgrouplist(resource $messagestore,
                               int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The companyid for which we are requesting the groups (optional)

Example 3.97. Listing groups

$array = mapi_zarafa_getgrouplist($msgstore);
		

mapi_zarafa_creategroup ()

Create a new group.

This function creates a new group with the specified name on the server. After creation, the group will contain no users. Returns TRUE if the group was created successfully, FALSE if the creation failed. You cannot create a group which already exists.

long mapi_zarafa_creategroup(resource $messagestore,
                             string $groupname);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupname
The name of the group to be created.

Example 3.98. Creating a group

$groupid = mapi_zarafa_creategroup($msgstore, "newgroup");
		

mapi_zarafa_deletegroup ()

Delete an existing group.

This function deletes a group on the server. Any users within this group are left untouched. Returns TRUE if the deletion was successful, FALSE if the group could not be deleted (not found).

boolean mapi_zarafa_deletegroup(resource $messagestore,
                                string $groupname);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupname
The name of the group to be created.

Example 3.99. Deleting a group

mapi_zarafa_deletegroup($msgstore,"newgroup");
		

mapi_zarafa_addgroupmember ()

Add a user to a group.

This function adds a user to an existing group. Returns TRUE on success, FALSE on failure (ie unknown user or unknown group)

boolean mapi_zarafa_addgroupmember(resource $messagestore,
                                   int $groupid,
                                   int $userid);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupid
The id of the group to add the user to.
$userid
The id of the user to add to the group.

Example 3.100. Adding a user to a group

mapi_zarafa_addgroupmember($msgstore,$groupid,$userid);
		

mapi_zarafa_deletegroupmember ()

Delete a user from a group.

This function deletes a user from an existing group. Returns TRUE on success, FALSE on failure (ie unknown user or unknown group)

boolean mapi_zarafa_deletegroupmember(resource $messagestore,
                                      int $groupid,
                                      int $userid);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupid
The id of the group to remove the user from.
$userid
The id of the user to remove from the group.

Example 3.101. Deleting a user from a group

mapi_zarafa_deletegroupmember($msgstore,$groupid,$userid);
		

mapi_zarafa_getgrouplistofuser ()

Get a list of groups for a specific user.

This function returns a list of groups in the same way as mapi_zarafa_getgrouplist, but only returns the groups of which the specified user is a member.

array mapi_zarafa_getgrouplistofuser(resource $messagestore,
                                     long $userid);
$messagestore
The resource id of the messagestore of the logged-on user.
$username
The id of the user to be queried.

Example 3.102. Getting groups of a user

$groups = mapi_zarafa_getgrouplistofuser($msgstore,2);
		

mapi_zarafa_getuserlistofgroup ()

Get a list of users for a specific group.

This function returns a list of users in the same way as mapi_zarafa_getuserlist, but only returns the users that are members of the specified group.

array mapi_zarafa_getuserlistofgroup(resource $messagestore,
                                     long $groupid);
$messagestore
The resource id of the messagestore of the logged-on user.
$groupid
The id of the group to be queried.

Example 3.103. Getting users of a group

$groups = mapi_zarafa_getuserlistofgroup($msgstore, 1);
		

mapi_zarafa_createcompany ()

Create a new company.

This function creates a new company with the specified name on the server. After creation, the company will contain no users. Returns TRUE if the company was created successfully, FALSE if the creation failed. You cannot create a company which already exists.

long mapi_zarafa_createcompany(resource $messagestore,
                               string $companyname);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyname
The name of the company to be created.

Example 3.104. Creating a company

$groupid = mapi_zarafa_createcompany($msgstore, "newcompany");
		

mapi_zarafa_deletecompany ()

Delete an existing company.

This function deletes a company on the server. Any users within this company are left untouched. Returns TRUE if the deletion was successful, FALSE if the company could not be deleted (not found).

boolean mapi_zarafa_deletecompany(resource $messagestore,
                                  string $companyname);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyname
The name of the company to be deleted.

Example 3.105. Deleting a company

mapi_zarafa_deletecompany($msgstore,"delcompany");
		

mapi_zarafa_getcompany_by_id ()

Retrieve company information for zarafa company.

Returns an associative array of information for the specified company, or FALSE of the company does not exist or an other error occurred. The associative array contains 'companyid' and 'companyname'.

array mapi_zarafa_getcompany_by_id(resource $messagestore,
                                   int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The id of the company whose information is te be returned

Example 3.106. Getting company information

$info = mapi_zarafa_getcompany_by_id($msgstore, 2);

print $info["companyid"];
print $info["companyname"];
		

mapi_zarafa_getcompany_by_name ()

Retrieve company information for zarafa company.

Returns an associative array of information for the specified company, or FALSE of the company does not exist or an other error occurred. The associative array contains 'companyid' and 'companyname'.

array mapi_zarafa_getcompany_by_name(resource $messagestore,
                                     string $company);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyname
The name of the company whose information is te be returned

Example 3.107. Getting company information

$info = mapi_zarafa_getcompany_by_name($msgstore, "default");

print $info["companyid"];
print $info["companyname"];
		

mapi_zarafa_getcompanylist ()

Get list of all companies

Returns an array of all companies on the server.Each list item is an associative array with the keys 'companyname' and 'companyid'. There are as many items in the returned array as there are companies

array mapi_zarafa_getcompanylist(resource $messagestore);
$messagestore
The resource id of the messagestore of the logged-on user.

Example 3.108. Listing companies

$array = mapi_zarafa_getcompanylist($msgstore);
		

mapi_zarafa_add_company_remote_viewlist ()

Add a company to the remote view list of a different company

This will add a company (setcompanyid) to the remote view list of a different company (companyid). This will allow the members of company 'companyid' to view the members of company 'setcompanyid'.

boolean mapi_zarafa_add_company_remote_viewlist(resource $messagestore,
                                                int $setcompanyid,
                                                int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$setcompanyid
The company to be added to the remote view list.
$companyid
The company which remote view list should be edited.

Example 3.109. Add a company to the remote view list of a different company

mapi_zarafa_add_company_remote_viewlist($msgstore, $setcompanyid, $companyid);
		

mapi_zarafa_del_company_remote_viewlist ()

Delete a company from the remote view list of a different company

This will delete a company (setcompanyid) from the remote view list of a different company (companyid). This will prevent the members of company 'companyid' to view the members of company 'setcompanyid'.

boolean mapi_zarafa_del_company_remote_viewlist(resource $messagestore,
                                                int $setcompanyid,
                                                int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$setcompanyid
The company to be deleted from the remote view list.
$companyid
The company which remote view list should be edited.

Example 3.110. Delete a company from the remote view list of a different company

mapi_zarafa_del_company_remote_viewlist($msgstore, $setcompanyid, $companyid);
		

mapi_zarafa_get_remote_viewlist ()

List all companies in the remote view list

This will return the remote view list for the specified company.

array mapi_zarafa_get_remote_viewlist(resource $messagestore,
                                      int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The company for which we are requesting the remote view list.

Example 3.111. List all companies in the remote view list

$companies = mapi_zarafa_get_remote_viewlist($msgstore, $companyid);
print_r($companies);
		

mapi_zarafa_add_user_remote_adminlist ()

Add a user to the remote admin list of a company

This will add a user to the remote admin list of a company. This will allow the user to perform administrator tasks over the specified company.

boolean mapi_zarafa_add_user_remote_adminlist(resource $messagestore,
                                              int $userid,
                                              int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$userid
The user to be added to the remote administrator list.
$companyid
The company for which the user will be set as administrator.

Example 3.112. Add a user to the remote admin list of a different company

mapi_zarafa_add_user_remote_adminlist($msgstore, $userid, $companyid);
		

mapi_zarafa_del_user_remote_adminlist ()

Delete a user from the remote admin list of a company

This will delete an user from the remote admin list of a company. This will strip the administrator rights for the user on the specified company.

boolean mapi_zarafa_del_user_remote_adminlist(resource $messagestore,
                                              int $userid,
                                              int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$userid
The user to be deleted from the remote administrator list.
$companyid
The company for which the user will no longer be administrator.

Example 3.113. Delete a user from the admin list of a company

mapi_zarafa_del_user_remote_adminlist($msgstore, $userid, $companyid);
		

mapi_zarafa_get_remote_adminlist ()

List all users in the remote admin list

This will return the remote admin list for the specified company.

array mapi_zarafa_get_remote_adminlist(resource $messagestore,
                                       int $companyid);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The company for which we are requesting the remote admin list.

Example 3.114. List all users in the remote admin list

$users = mapi_zarafa_get_remote_adminlist($msgstore, $companyid);
print_r($users);
		

mapi_zarafa_add_quota_recipient ()

Add a recipient to the recipient list of a company

When a user exceeds his quota, he will receive a warning email. With this function you can edit the list of additional recipients for this email. With the type argument you can set if the recipient list of userquota or companyquota warnings should be edited.

boolean mapi_zarafa_add_quota_recipient(resource $messagestore,
                                        int $companyid,
                                        int $recipient,
                                        int $type);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The company for which to edit the recipientlist.
$recipientid
The user to be added to the recipientlist.
$type
The recipientlist type (USEROBJECT_TYPE_USER or USEROBJECT_TYPE_COMPANY).

Example 3.115. Add a recipient to the recipient list of a company

mapi_zarafa_add_quota_recipient($msgstore, $companyid, $recipientid, USEROBJECT_TYPE_COMPANY);
		

mapi_zarafa_del_quota_recipient ()

Delete a recipient from the recipient list of a company

When a user exceeds his quota, he will receive a warning email. With this function you can edit the list of additional recipients for this email. With the type argument you can set if the recipient list of userquota or companyquota warnings should be edited.

boolean mapi_zarafa_del_quota_recipient(resource $messagestore,
                                        int $companyid,
                                        int $recipientid,
                                        int $type);
$messagestore
The resource id of the messagestore of the logged-on user.
$companyid
The company for which to edit the recipientlist.
$recipientid
The user to be removed from the recipientlist.
$type
The recipientlist type (USEROBJECT_TYPE_USER or USEROBJECT_TYPE_COMPANY).

Example 3.116. Delete a recipient from the recipient list of a company

mapi_zarafa_del_quota_recipient($msgstore, $companyid, $userid, USEROBJECT_TYPE_COMPANY);
		

mapi_zarafa_get_quota_recipientlist ()

List all users in the recipient list

When a user exceeds his quota, he will receive a warning email. With this function you can request the list of additional recipients for this email. The userid as argument can either be a userid or companyid.

array mapi_zarafa_get_quota_recipientlist(resource $messagestore,
                                          int $userid);
$messagestore
The resource id of the messagestore of the logged-on user.
$userid
The user for which we are requesting the recipientlist.

Example 3.117. List all users in the recipient list

$users = mapi_zarafa_get_quota_recipientlist($msgstore, $userid);
print_r($users);
		

mapi_zarafa_getpermissionrules ()

Get a list of ACLs from an object.

This function returns an array of set ACLs of the requested type.

The type field is one of: ACCESS_TYPE_DENIED, ACCESS_TYPE_GRANT, ACCESS_TYPE_BOTH

The 'rights' field in the array is the access value. These values are defined in the ecRights* defines, found in include/mapidefs.php. The values are bitwise OR-ed. 1531 == 0x5FB == ecRightsAll.

The state field is one of: RIGHT_NORMAL, RIGHT_NEW, RIGHT_MODIFY, RIGHT_DELETED, RIGHT_AUTOUPDATE_DENIED. In the mapi_zarafa_getpermissionrules(), only RIGHT_NORMAL is returned.

array mapi_zarafa_getpermissionrules(resource $mapiobject,
                                     long $acl_type);
$mapiobject

This is a mapi object. It can be a store, folder, message or attachment.

Note: Only ACLs on the store and on a folder work.

$acl_type
The ACL type to query. This is one of: ACCESS_TYPE_DENIED, ACCESS_TYPE_GRANT, ACCESS_TYPE_BOTH

Example 3.118. Getting the ACL list of the store.

$acls = mapi_zarafa_getpermissionrules($msgstore, ACCESS_TYPE_GRANT);
print_r($acls);
		

Output:

Array
(
    [0] => Array
        (
            [userid] => 4
            [type] => 2
            [rights] => 1531
            [state] => 0
        )

)
		

mapi_zarafa_setpermissionrules ()

Set a list of ACLs on an object.

This function sets returns an array of set ACLs of the requested type.

Each entry contains the following fields: userid, type, rights, state.

Userid
This is an id from a user. Use mapi_getuserlist() to get all valid users.
Type
Type is one off: ACCESS_TYPE_DENIED, ACCESS_TYPE_GRANT, ACCESS_TYPE_BOTH .
Rights
Rights is an OR-ed value, by ecRights* defines, found in include/mapi/mapidefs.php.
State
State is one of: RIGHT_NEW, RIGHT_MODIFY, RIGHT_DELETED . RIGHT_NORMAL is not used, since it is no update action. RIGHT_AUTOUPDATE_DENIED can be OR-ed to an action to automatically set the inverted DENY action.

boolean mapi_zarafa_setpermissionrules(resource $mapiobject,
                                       array $acls);
$mapiobject

This is a mapi object. It can be a store, folder, message or attachment.

Note: Only ACLs on the store and on a folder work.

$acls
An Array containing ACL settings.

Example 3.119. Setting the ACL list on the inbox.

$acls = array( 0 => array(
		'userid'	=> 3,
		'type'		=> ACCESS_TYPE_GRANT,
		'rights'	=> ecRightsFullControl,
		'state'		=> RIGHT_NEW | RIGHT_AUTOUPDATE_DENIED
	)
);

$ret = mapi_zarafa_setpermissionrules($inbox, $acls);
		

mapi_inetmapi_imtoinet ()

Converts a MAPI Message into an RFC822-formatted e-mail stream.

Session
Session from which the passed message can be opened
Addressbook
Addressbook for looking up ZARAFA adresses to be converted into SMTP addresses
Message
The message to be converted
Flags
Reserved for future use.

stream mapi_inetmapi_imtoinet(resource $session,
                              resource $addrbook,
                              resource $message,
                              array $flags);
$session
Session on which the message was opened
$addrbook
Addressbook to resolve email addresses
$message
Message to convert to RFC822
$flags
Reserved.