getUnreadRequest

WebAccess needed a way to get the list of unread items in the user’s mailbox. The list needs to be returned as quickly as possible. This is a specialized call to return that list. There are a few parameters to qualify the list returned. The list returned is a list of sid's (short identifiers). Once you have the list you can pass the sid's in a getItemsRequest to return part or all of the items. --For GroupWise 2012 and later.

Request

<getUnreadRequest>
  <startDate type="dateTime" minOccurs="0"/>
  <types type="string" minOccurs="0"/>
  <source type="xs:string" minOccurs="0"/>
</getUnreadRequest>

Response

<getUnreadResponse>
  <sids type="xs:string" minOccurs="0"/>
  <status type="types:Status"/>
</getUnreadResponse>

Elements

startDate

If specified, return items with a startDate greater than or equal to the date. (For Mail, PhoneMessage or DocumentReference, it compares the value against the created date.)

types

A space delimited string of item types to include in the search. You can have one or more of the following values

  • Mail

  • Appointment

  • Note

  • Task

  • PhoneMessage

  • DocumentReference

  • CalendarItem

    (This includes appointments, notes and tasks.)

If you don't supply a value for "types", appointments, mail, notes, tasks and phone messages are returned.

source

A space delimited string of box types to include in the search. You can have one or more of the following values:

  • received

  • sent

  • personal (posted)

  • draft

If you do not supply a value, received, personal and draft items is returned.

sids

The return value is a space-delimited list of sids of the matching items matching the query.

status

The query returns approximately 4000 items. If there are more items available, a D11B (53531) WPF_WARN_TOO_MANY_RECORDS error is returned. To get more items, you must adjust the startDate value and call getUnreadRequest again.

Example

Here is some sample code. It gets the unread items. If there are too many items, it reads the last item, finds the startDate, and uses that to read the next set of sids.

NOTE:You might have some duplicate sids in this case. You must merge the sets.

  public void testFindUnread() {
    Calendar start = null;
    GetUnreadResponse   uresp = null;
    GetItemsResponse    resp = null;
    int i = 0;
    ItemRefList list = null;
    String read;
    String  str;
    String  view = "id sid status subject startDate created";
    String [] items = null;
    String [] one   = {""};
    StringTokenizer tokens;
        
    try {
      uresp = m_main.getService().getUnreadRequest( null, "Mail CalendarItem",
         null, m_main.getSessionId(), m_main.getTrace() );
      if ( null == uresp.getStatus() ) {
        return;
      }
            
      if ( !(0 == uresp.getStatus().getCode() || 
        0xd11b == uresp.getStatus().getCode() ) ) {
        m_main.displayError( uresp.getStatus(), "testFindUnread" );
        return;
      }
      tokens = new StringTokenizer( uresp.getSids(), " " );
      m_main.displayString( "Count = " + String.valueOf(tokens.countTokens())
         );
      if ( 0xd11b == uresp.getStatus().getCode() ) {
        items = new String[ tokens.countTokens() ];
        while ( tokens.hasMoreTokens() ) {
          one[ 0 ] = items[ i++ ] = tokens.nextToken();
        }            
        list = new ItemRefList( one );
        resp = m_main.getService().getItemsRequest( "folders", view, null,
           list, 0, m_main.getSessionId(), m_main.getTrace() );
        start = ((Mail)(resp.getItems().getItem()[0])).getCreated();
        uresp = m_main.getService().getUnreadRequest( start, 
           "Mail CalendarItem", null, m_main.getSessionId(), m_main.getTrace()
           );
        tokens = new StringTokenizer( uresp.getSids(), " " );
        m_main.displayString( "Count = " + 
           String.valueOf(tokens.countTokens()) );
      }
    } catch ( Exception ex ) {
      ex.printStackTrace();
    }
  }
SOAP Trace
<getUnreadRequest>
  <types>Mail CalendarItem</types>
</getUnreadRequest>
<getUnreadResponse>
  <sids>260815 264110 270837 ... 283851 283848 283845 283842 283839</sids>
  <status>
    <code>53531</code>
    <description>More than 5000 records</description>
  </status>
</getUnreadResponse>
<getItemsRequest>
  <container>folders</container>
  <view>id sid status subject startDate created</view>
  <items>
    <item >283839</item>
  </items>
</getItemsRequest>
<getItemsResponse>
  <items>
    <item type="Mail">
      <id>4E92DD25.domain.PO1.100.1776172.1.454BF.1@1:4B82436A.
         domain.PO1.100.1776172.1.E062.1@13</id>
      <sid>283839</sid>
      <container sid="57442">4B82436A.domain.PO1.100.1776172.1.E062.1@13
         </container>
      <created>2011-10-10T17:55:17Z</created>
      <source>received</source>
      <delivered>2011-10-10T17:55:17Z</delivered>
      <subject>test three [962]</subject>
    </item>
  </items>
  <status>
    <code>0</code>
  </status>
</getItemsResponse>
<getUnreadRequest>
  <startDate>2011-10-10T17:55:17.000+00:00</startDate>
  <types>Mail CalendarItem</types>
</getUnreadRequest>
<getUnreadResponse>
  <sids>283851 283848 283845 ... 287055 287056</sids>
  <status>
    <code>0</code>
  </status>
</getUnreadResponse>