delete form from personal forms library

  • Thread starter Thread starter Vadiraj
  • Start date Start date
V

Vadiraj

Hi,
I have a form in my Personal forms library with a message
class "IPM.Note.xxx" and with a display name "xxx"

Can any body let me know how to programatically delete or
hide that form using vb code

If possible please send me the code snippet

Thanks in advance

Regards
Vadiraj
 
You can do that, but not using the Outlook object model. Each custom form
published in the Personal Forms library lives as a hidden message in the
hidden Common Views folder with a MessageClass of
"IPM.Microsoft.FolderDesign.FormsDescription". MAPI property 0x6800001E has
the custom message class of the form as a string property.

This requires coding in CDO 1.21 (optional installation for Outlook 2000 and
later) or Extended MAPI (C++ or Delphi only) to get at the Common Views
folder.

CDO code would look something like this when run from within Outlook (so an
Outlook session is already established). This code requires a project
reference to be set to CDO.DLL which is CDO 1.21:

Dim oSession As MAPI.Session
Dim oInbox As MAPI.Folder
Dim oRoot As MAPI.Folder
Dim oStore As MAPI.InfoStore
Dim oViews As MAPI.Folder
Dim oMessage As MAPI.Message
Dim oFolders As MAPI.Folders
Dim oMessages As MAPI.Messages
Dim sMessageClass As String

Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oInbox = oSession.Inbox
Set oStore = oSession.GetInfoStore(oInbox.StoreID)
Set oRoot = oStore.RootFolder
Set oFolders = oRoot.Folders

'for Outlook 2003 use "IPM_Common_Views" instead
Set oView = oFolders.Item("Common Views")
Set oMessages = oView.HiddenMessages
For Each oMessage In oMessages
If oMessage.Type = "IPM.Microsoft.FolderDesign.FormsDescription" Then
sMessageClass = oMessage.Fields(&H6800001E)
If sMessageClass = "IPM.Note.xxx" Then
oMessage.Delete
Exit For
End If
Next

oSession.Logoff
'now set all objects = Nothing
 
Ken,
I tried ur code but it is not removing the form from
personal forms library
Please let me know what needs to be done in achieving the
same

Thanks and Regards
Vadiraj
-----Original Message-----
You can do that, but not using the Outlook object model. Each custom form
published in the Personal Forms library lives as a hidden message in the
hidden Common Views folder with a MessageClass of
"IPM.Microsoft.FolderDesign.FormsDescription". MAPI property 0x6800001E has
the custom message class of the form as a string property.

This requires coding in CDO 1.21 (optional installation for Outlook 2000 and
later) or Extended MAPI (C++ or Delphi only) to get at the Common Views
folder.

CDO code would look something like this when run from within Outlook (so an
Outlook session is already established). This code requires a project
reference to be set to CDO.DLL which is CDO 1.21:

Dim oSession As MAPI.Session
Dim oInbox As MAPI.Folder
Dim oRoot As MAPI.Folder
Dim oStore As MAPI.InfoStore
Dim oViews As MAPI.Folder
Dim oMessage As MAPI.Message
Dim oFolders As MAPI.Folders
Dim oMessages As MAPI.Messages
Dim sMessageClass As String

Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oInbox = oSession.Inbox
Set oStore = oSession.GetInfoStore(oInbox.StoreID)
Set oRoot = oStore.RootFolder
Set oFolders = oRoot.Folders

'for Outlook 2003 use "IPM_Common_Views" instead
Set oView = oFolders.Item("Common Views")
Set oMessages = oView.HiddenMessages
For Each oMessage In oMessages
If oMessage.Type
= "IPM.Microsoft.FolderDesign.FormsDescription" Then
 
Are you getting any error messages? Did you try to debug the code and step
through it? Do you have CDO 1.21 installed (optional with Outlook 2000 and
later) and did you set a reference to CDO.DLL in your project? "Doesn't
work" doesn't tell us anything.
 
Hmm, how about using PR_COMMON_VIEWS_ENTRYID (0x35E60102) from IMsgStore
(InfoStore)? That should work and be language independent.
 
Works perfectly! Updated version posted at
http://www.outlookcode.com/codedetail.aspx?id=572. I imagine it will be not
just language-independent but version-independent as well, but I tested it
only for OL2003.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Ken Slovak - said:
Hmm, how about using PR_COMMON_VIEWS_ENTRYID (0x35E60102) from IMsgStore
(InfoStore)? That should work and be language independent.
Sue Mosher said:
Ken, I have also been seeing odd things with the form removal code. It runs
without errors but the final For Each ... Next loop doesn't find any of the
forms that I see in IPM_COMMON_VIEWS in Outlook Spy. Instead, if I enumerate
all the items in that folder with a Debug.Print statement, all it finds are
three custom views, three views that I don't even see in
IPM_COMMON_VIEWS.
From the symptoms, I'd say that oFolders.Item("IPM_COMMON_VIEWS") is opening
the wrong folder.

Can you think of any other way to return system folders from the root?

"Ken Slovak - [MVP - Outlook]" wrote:
 
Excellent.

The property is there in OutlookSpy in Outlook 2000 and 2002 here. I'm not
running any earlier versions but it should be there too.
 
Back
Top