• Sign In
 
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • Advanced search options...
  • About
  • Email Blog Author
  • RSS for posts
  • Atom
  • RSS for comments
    • OK
  • CDO (20)
  • Code Snippet (42)
  • Custom Providers (15)
  • Debugging (7)
  • DevMsgTeam (278)
  • Documentation (101)
  • DST (8)
  • EWS (7)
  • Exchange (100)
  • Gotchas (91)
  • Hotfix (28)
  • MAPI (220)
  • MAPI Download (48)
  • MFCMAPI (92)
  • MSDN (54)
  • Non Dev (11)
  • OOM (17)
  • Outlook (163)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (11)
  • Protocol Docs (20)
  • PST/OST (22)
  • Referrals (8)
  • Vista (12)
  • WrapPST (15)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)
Blogs I Read
  • Exchange

  • Raymond Chen [MSFT]

  • Larry Osterman [MSFT]

  • Peter David

  • Aaron Margosis [MSFT]

  • Jason Johnston [MSFT]

  • Matt Stehle (MSFT)

  • Patrick Creehan [MSFT]

  • Ryan Gregg [MSFT]

    Outlook PM
  • WebDav 101

    Dan Bagley (MSFT)
  • Dave Vespa [MSFT]

  • Randy Topken

    Outlook EE

December, 2005

MSDN Blogs > SGriffin's MAPI Internals > December, 2005
  • Subscribe via RSS
Sort by: Most Recent | Most Views | Most Comments
Excerpt View | Full Post View
  • SGriffin's MAPI Internals

    New Outlook Documentation Part 5 - One-Off Forms

    Posted over 7 years ago
    by Stephen Griffin - MSFT
    • 5 Comments

    [This is now documented here: http://msdn2.microsoft.com/en-us/library/bb820932.aspx]

    This should help dealing with scenarios in Outlook that cause forms to become one-offed.

    Topic
    How to remove one-off form attributes from a message which has unexpectedly been “one-offed”.

    One-Off Forms
    A message which has been “one-offed” is one where a custom form definition has been saved with the message. While there are legitimate scenarios for one-offing a form, typically this happens unexpectedly. The negative side effects and descriptions of how messages can become one-offed are discussed in the following Knowledge Base article:
    http://support.microsoft.com/kb/207896

    Removing One-Off  Properties
    A message which has been marked as a one-off can be restored to a regular message by deleting a set of named properties and removing some flags from another named property. This process can be done with Extended MAPI or CDO. The properties which must be deleted are all in the PSETID_Common namespace and are dispidFormStorage, dispidPageDirStream, dispidFormPropStream, and dispidScriptStream. The property which must be modified is also in the PSETID_Common namespace. The flags INSP_ONEOFFFLAGS must be removed from dispidCustomFlag.

    In addition, the property dispidPropDefStream in the PSETID_Common namespace may also be removed. If this property is removed, then the flag INSP_PROPDEFINITION should be removed from dispidCustomFlag. A side effect of removing this property is that the Outlook Object Model and the Outlook User Interface will no longer be able to access user properties which have been set on the item. These properties and their values will still be accessible through MAPI. Note that if this property is not removed and the items is one-offed again, it is possible that the property can be overwritten with new data.

    Definitions

    #define dispidFormStorage    0x850F
    #define dispidPageDirStream  0x8513
    #define dispidFormPropStream 0x851B
    #define dispidPropDefStream  0x8540
    #define dispidScriptStream   0x8541
    #define dispidCustomFlag     0x8542
    
    #define INSP_ONEOFFFLAGS     0xD000000
    #define INSP_PROPDEFINITION  0x2000000
    
    DEFINE_OLEGUID(PSETID_Common, MAKELONG(0x2000+(8),0x0006),0,0);

    Usage
    The following sample code illustrates how to remove one-off attributes from a message using Extended MAPI:

    ULONG aulOneOffIDs[] = {dispidFormStorage, 
    dispidPageDirStream,
    dispidFormPropStream,
    dispidScriptStream,
    dispidPropDefStream, // dispidPropDefStream must remain next to last in list
    dispidCustomFlag}; // dispidCustomFlag must remain last in list
    
    #define ulNumOneOffIDs (sizeof(aulOneOffIDs)/sizeof(aulOneOffIDs[0]))
    
    HRESULT RemoveOneOff(LPMESSAGE lpMessage, BOOL bRemovePropDef)
    {
      if (!lpMessage) return MAPI_E_INVALID_PARAMETER;
    
      HRESULT hRes = S_OK;
      MAPINAMEID  rgnmid[ulNumOneOffIDs];
      LPMAPINAMEID rgpnmid[ulNumOneOffIDs];
      LPSPropTagArray lpTags = NULL;
    
      ULONG i = 0;
      for (i = 0 ; i < ulNumOneOffIDs ; i++)
      {
        rgnmid[i].lpguid = (LPGUID)&PSETID_Common;
        rgnmid[i].ulKind = MNID_ID;
        rgnmid[i].Kind.lID = aulOneOffIDs[i];
        rgpnmid[i] = &rgnmid[i];
      }
      
      hRes = lpMessage->GetIDsFromNames(
        ulNumOneOffIDs,
        rgpnmid,
        0,
        &lpTags);
      if (lpTags)
      {
        // The last prop is the flag value 
        // we'll be updating, don't count it
        lpTags->cValues = ulNumOneOffIDs-1;
    
        // If we're not removing the prop def stream don't count it
        if (!bRemovePropDef)
        {
          lpTags->cValues = lpTags->cValues-1;
        }
    
        hRes = lpMessage->DeleteProps(
          lpTags,
          0);
        if (SUCCEEDED(hRes))
        {
          SPropTagArray  pTag = {0};
          ULONG      cProp = 0;
          LPSPropValue  lpCustomFlag = NULL;
    
          // Grab dispidCustomFlag, the last tag in the array
          pTag.cValues = 1;
          pTag.aulPropTag[0] = CHANGE_PROP_TYPE(
            lpTags->aulPropTag[ulNumOneOffIDs-1],
            PT_LONG);
    
          hRes = lpMessage->GetProps(
            &pTag,
            fMapiUnicode,
            &cProp,
            &lpCustomFlag);
          if (SUCCEEDED(hRes) && 
            1 == cProp && lpCustomFlag && 
            PT_LONG == PROP_TYPE(lpCustomFlag->ulPropTag))
          {
            // Clear the INSP_ONEOFFFLAGS bits so OL 
            // doesn't look for the props we deleted
            lpCustomFlag->Value.l = 
              lpCustomFlag->Value.l&~(INSP_ONEOFFFLAGS);
            if (bRemovePropDef)
            {
              lpCustomFlag->Value.l = 
               lpCustomFlag->Value.l&~(INSP_PROPDEFINITION);
            }
            hRes = lpMessage->SetProps(
              1,
              lpCustomFlag,
              NULL);
          }
    
          hRes = lpMessage->SaveChanges(KEEP_OPEN_READWRITE);
        }
      }
      MAPIFreeBuffer(lpTags);
    
      return hRes;
    }

     

    The following sample code illustrates how to remove one-off attributes from a message using CDO 1.21:

    Sub DeleteFormDefinitionWithCDO(MessageEID As String, bDeletePropDef As Boolean)
      Const strPSetCommonGUID = "0820060000000000C000000000000046" ' PSETID_Common
    
      Dim objSession As MAPI.Session
      Dim oFolderCDO As MAPI.Folder
      Dim oMessages As MAPI.Messages
      Dim oMessage As MAPI.Message
      Dim myFields As MAPI.Fields
    
      Set objSession = New MAPI.Session
      objSession.Logon , , True, False
      Set oMessage = objSession.GetMessage(MessageEID)
      Set myFields = oMessage.Fields
      On Error Resume Next
      myFields.Item("{" & strPSetCommonGUID & "}0x850F").Delete ' dispidFormStorage
      myFields.Item("{" & strPSetCommonGUID & "}0x8513").Delete ' dispidPageDirStream
      myFields.Item("{" & strPSetCommonGUID & "}0x851B").Delete ' dispidFormPropStream
      myFields.Item("{" & strPSetCommonGUID & "}0x8541").Delete ' dispidScriptStream
      ' Update dispidCustomFlag
      myFields.Item("{" & strPSetCommonGUID & "}0x8542") = _
        myFields.Item("{" & strPSetCommonGUID & "}0x8542") And Not &HD000000 ' INSP_ONEOFFFLAGS
    
      If bDeletePropDef Then
        myFields.Item("{" & strPSetCommonGUID & "}0x8540").Delete ' dispidPropDefStream
        myFields.Item("{" & strPSetCommonGUID & "}0x8542") = _
          myFields.Item("{" & strPSetCommonGUID & "}0x8542") And Not &H2000000 ' INSP_PROPDEFINITION
      End If
    
      oMessage.Update
      objSession.Logoff
      Set objSession = Nothing
    End Sub
Page 1 of 1 (1 items)
  • © 2012 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy Statement
  • Report Abuse
  • 5.6.402.223