imap_get_attribute_int_ex
| Internet Messaging Functions (IMAP) |
Obtains a IMAP attribute for a specific session.
int imap_get_attribute_int_ex( IMAP *ppimap, char *attribute );
| ppimap | A session identifier. |
| attribute | The IMAP attribute to retrieve. The available attributes are: RECENT_MESSAGE_COUNT - Returns the number of recent messages in selected mailboxTOTAL_MESSAGE_COUNT - Total number of messages in selected mailboxUNSEEN_MESSAGE_COUNT - Total number of unseen message in selected mailboxREAD_WRITE_MODE - Mode of selected mailbox: "[READ-WRITE]" or "[READ-ONLY]".NEXT_MESSAGE_UID - Next valid UID in selected mailboxMAILBOX_UID - Mailbox Identifier |
The imap_get_attribute_int_ex function returns the value of an IMAP attribute for a specific session, as an integer.
The values should be refreshed before calling imap_get_attribute_int_ex. The RECENT_MESSAGE_COUNT and TOTAL_MESSAGE_COUNT attributes are updated during a call to imap_select_mailbox function. The other attributes are updated by a call to imap_status_ex.
This function is for use with multiple sessions. For global sessions, use the imap_get_attribute_int function, which leaves out the session identifier.
Return Values
If this function succeeds, it returns the value of the specified property. Otherwise, it returns LR_FAIL.
Parameterization
All arguments of this function of the type char, can be parameterized with standard parameterization.
Example
In the following example, the imap_get_attribute_int_ex function retrieves the IMAP session attributes.
int temp;
int numMessage;
vuser_init() {
imap1 = 0;
imap_logon_ex(&imap1, "IMapLogon",
"URL=imap://qatest:qatest@aqwa.abc.co.il", LAST );/* Selecting the mailbox refreshes the values of RECENT_MESSAGE_COUNT, READ_WRITE_MODE, and TOTAL_MESSAGE_COUNT, making them available to the subsequent call to imap_get_attribute_int_ex. */
imap_select_ex(&imap1, "SelectMailbox", "Mailbox=Sent Items", LAST );
// Output the total message count
numMessage = imap_get_attribute_int_ex(&imap1,"TOTAL_MESSAGE_COUNT");
lr_output_message("total message count: %d", numMessage);// Output the recent message count
numMessage = imap_get_attribute_int_ex(&imap1,"RECENT_MESSAGE_COUNT");
lr_output_message("Recent message count: %d", numMessage);// Output the read/write mode (read-write = 1)
temp = imap_get_attribute_int_ex(&imap1, "READ_WRITE_MODE");
lr_output_message("READ_WRITE_MODE = %d", temp);/* This call to imap_status_ex refreshes the values for:
TOTAL_MESSAGE_COUNT (MESSAGES)
RECENT_MESSAGE_COUNT (RECENT)
UNSEEN_MESSAGE_COUNT (UNSEEN)
NEXT_MESSAGE_UID (UIDNEXT)
MAILBOX_UID (UIDVALIDITY).
Note that you don't have to call imap_status_ex with all the values.
For example:
imap_status_ex(&imap1, "MailboxStatus",
"Mailbox=Sent Items (UIDVALIDITY)",LAST ); temp = imap_get_attribute_int_ex(&imap1, "MAILBOX_UID");
lr_output_message("MAILBOX_UID = %d", temp); */imap_status_ex(&imap1, "MailboxStatus", "Mailbox=Sent Items (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)", LAST );
// Output the ID of the next message that will be added after all the existing messages
temp = imap_get_attribute_int_ex(&imap1, "NEXT_MESSAGE_UID");
lr_output_message("NEXT_MESSAGE_UID = %d", temp);// Output the number of messages that haven't been read
temp = imap_get_attribute_int_ex(&imap1, "UNSEEN_MESSAGE_COUNT");
lr_output_message("UNSEEN_MESSAGE_COUNT = %d", temp);// Output the mailbox ID
temp = imap_get_attribute_int_ex(&imap1, "MAILBOX_UID");
lr_output_message("MAILBOX_UID = %d", temp);
imap_close_ex(&imap1, "CloseMailbox", LAST );
imap_logout_ex(&imap1);
imap_free_ex(&imap1);
return 0;
}

