I have a C3PO (utilizing the Object API)...
Articles and Tips: qna
01 Jul 2003
Q.
I have a C3PO (utilizing the Object API) that adds a toolbar button to GroupWise. The button is only enabled when a message has a "valid" attachment (the code snippet below explains what I mean by "valid" attachment).
My problem is that my code to determine whether the button should be enabled or not causes "Unread" messages (in bold type) in the user's inbox to automatically appear as "Read" (unbolded). Understandably, the users do not like this, because they haven't read the message.
I narrowed the problem down to the IGWAttachments::Item() method. Once this is called, the message changes from "unread" to "read," but I don't know why. Is this the correct behavior? I include for completeness a code snippet of the method that determines whether the button is enabled or not:
bool ObjAddMessageAndAttachmentCmd::isEnabledInBrowserContext (IGWClientState2 *pIClientState) { IDispatch *pIDisp; bool retval = false; // In the client browser window, we need to ensure that there is // one (and only one) message selected, and that the selected // message is the correct type, and has at least 1 attachment // Get the list of currently selected messages IGWMessageList *pMsgs; pIClientState->get_SelectedMessages(&pIDisp); pIDisp->QueryInterface (IID_IGWMessageList, (void **)&pMsgs); pIDisp->Release(); LONG lMsgCount = 0; pMsgs->get_Count (&lMsgCount); if (lMsgCount == 1) { VARIANT vTmp; DIGWMessage *pDIGMessage; IGWMessage2 *pIMessage; VariantInit(&vTmp); V_VT(&vTmp) = VT_I4; V_I4(&vTmp) = 1; // Get Message interface pMsgs->Item(vTmp, &pDIGMessage); if ( SUCCEEDED(pDIGMessage->QueryInterface (IID_IGWMessage2, (LPVOID *)&pIMessage))) { // has the message been read? VARIANT_BOOL vb; pIMessage->get_Read(&vb); // get a pointer the the messages attachments DIGWAttachments *pDIGWAttachments; if( SUCCEEDED( pIMessage->get_Attachments( &pDIGWAttachments ) ) ) { IGWAttachments *pIGWAttachments; if (SUCCEEDED(pDIGWAttachments->QueryInterface( IID_IGWAttachments, (LPVOID*)&pIGWAttachments ) ) ) { long attachCount=0; pIGWAttachments->get_Count (&attachCount); for( long i = 1; i <= attachCount; i++ ) { DIGWAttachment *pDIGWAttachment; IGWAttachment *pIGWAttachment; VARIANT vIdx; VariantInit( &vIdx ); V_VT( &vIdx ) = VT_I4; V_I4( &vIdx ) = i; if (SUCCEEDED( pIGWAttachments->Item( vIdx, &pDIGWAttachment ) ) ) { if (SUCCEEDED (pDIGWAttachment-> QueryInterface( IID_IGWAttachment, ( LPVOID* ) &pIGWAttachment ) ) ) { BSTR displayName; pIGWAttachment->get_DisplayName( &displayName ); if (wcsicmp(displayName, L"mime.822") != 0 && wcsicmp(displayName, L"text.htm") != 0) { retval = true; } pIGWAttachment->Release(); } pDIGWAttachment->Release(); } } pIGWAttachments->Release(); } pDIGWAttachments->Release(); } pIMessage->put_Read(vb); pIMessage->Release(); } pDIGMessage->Release(); } return retval; }
A.
This is correct behavior. The security is set up such that if you read a message with the API (which you are when you check the attachment), then the document is read. You can, however, reset the property to False. There is also an Opened property which cannot be reset to False, once the message has been opened. See the documentation for the Message base class.
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.