Example: imap_get_attribute_int_ex

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;
}