OL 2007 - Set custom form region as default

F

Fidget Brain

I created a custom form region with the following message class:
"IPM.Contact.TestAddIn1.ClientRegion". I then created a new Folder within
the default Contacts folder to store these custom items. Finally, I created
a NavigationFolder within the Contacts navigation module which points to my
new Folder.

when I click the navigation pane folder it is raising the default Contacts
form, rather than my custom form. this is expected. the problem is that I
can't find a way to set my custom message class for this folder in order to
correct this problem. The DefaultMessageClass property of my folder is
read-only. Also when I first create my folder, the help file specifies that
the additional optional parameter should specify an olDefaultFolder type, so
I can't set it there either.

any help appreciated as Ive been stuck on this now for a while :(
 
S

Sue Mosher [MVP-Outlook]

Since form regions do not themselves have message classes, I'm a little confused both about what you've done and about what you're trying to do with the form region. Maybe you can post your region's manifest or at least explain whether you're trying to do an adjoining or separate region.

If you want users to use a custom form to create items in your folder, create and publish a traditional Outlook form with the desired message class and set it as the folder's default on the Properties dialog for the form.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

John Guin

You should be able to right click on the folder, select Properties and use
the "When posting to this folder" to select the region you want.

You must have registered the region as a replace or replaceAll region, which
is sounds like you did according to the message class.

John
 
F

Fidget Brain

please accept my aplogies if i did not explain myself well enough. i will
try again.

i have created a .NET form region which has a formRegionType of
'separateAll'. my form region is an embedded resource. i can open it from
the command bar with the following code and it works fine:
const string clientsMessageClass = "IPM.Contact.TestAddin1.Client";

Outlook.ContactItem contactItem =
(Outlook.ContactItem)clientsFolder.Items.Add(clientsMessageClass);

contactItem.MessageClass = clientsMessageClass;

contactItem.Display(objMissing);

now i am trying to create a new NavigationItem within the Contacts
navigation pane to access this form region. So i am doing code like this,
where 'clientFolder' is a MAPI Folder I have created within the default
Contacts MAPI Folder as a place to store any custom items generated from my
custom form:
Outlook.NavigationFolder myCustomNavigationFolder =
myCustomNavigationGroup.NavigationFolders.Add(clientsFolder);

ok - so my problem is that whenever I double click my new NavigationItem it
is opening the default contacts form. i want it to open my custom form
region.

Since form regions do not themselves have message classes, I'm a little
confused both about what you've done and about what you're trying to do with
the form region. Maybe you can post your region's manifest or at least
explain whether you're trying to do an adjoining or separate region.

If you want users to use a custom form to create items in your folder,
create and publish a traditional Outlook form with the desired message class
and set it as the folder's default on the Properties dialog for the form.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Fidget Brain

sorry i forgot to mention

manually right clicking the folder to achieve this is no good to me. this is
a .NET add-in that will be shipped out to users, so i am asuming that I can
do this programmatically.
 
S

Sue Mosher [MVP-Outlook]

You'll have to settle for doing it manually at present. There apparently is a bug in Beta 2 related to using PropertyAccessor to set folder properties. Otherwise, you'd be able to use something like (VBA prototype):

Sub SetDefaultFormFolder(fld As Outlook.Folder, _
formClass As String, formName As String)
Dim pa As Outlook.PropertyAccessor
Dim propNames()
Dim propValues()
Dim arrErrors()
strPR_DEF_POST_MSGCLASS = _
"http://schemas.microsoft.com/mapi/proptag/0x36E5001E"
strPR_DEF_POST_DISPLAYNAME = _
"http://schemas.microsoft.com/mapi/proptag/0x36E6001E"
'On Error Resume Next

If Not fld Is Nothing Then
propNames() = Array(strPR_DEF_POST_MSGCLASS, _
strPR_DEF_POST_DISPLAYNAME)
propValues() = Array(formClass, formName)
Set pa = fld.PropertyAccessor
arrErrors = pa.SetProperties(propNames, propValues)
If Not (IsEmpty(arrErrors)) Then
'Examine the arrErrors array to determine if any
'elements contain errors
For i = LBound(arrErrors) To UBound(arrErrors)
'Examine the type of the element
If IsError(arrErrors(i)) Then
Debug.Print (CVErr(arrErrors(i)))
End If
Next
End If

End If
Set pa = Nothing
End Sub

Alternatively, if your add-in creates the folder, then you could deploy it by including a .pst file as a project resource, with the folder in that file, already prepopulated with the desired properties. Your code would simply copy the folder to the user's existing folder hierarchy.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

Store properties from PropertyAccessor too. You have to exit and restart
Outlook before changes you make are readable in the OOM, although OutlookSpy
sees them immediately. Something to do with caching properties I imagine.




You'll have to settle for doing it manually at present. There apparently is
a bug in Beta 2 related to using PropertyAccessor to set folder properties.
Otherwise, you'd be able to use something like (VBA prototype):

Sub SetDefaultFormFolder(fld As Outlook.Folder, _
formClass As String, formName As String)
Dim pa As Outlook.PropertyAccessor
Dim propNames()
Dim propValues()
Dim arrErrors()
strPR_DEF_POST_MSGCLASS = _
"http://schemas.microsoft.com/mapi/proptag/0x36E5001E"
strPR_DEF_POST_DISPLAYNAME = _
"http://schemas.microsoft.com/mapi/proptag/0x36E6001E"
'On Error Resume Next

If Not fld Is Nothing Then
propNames() = Array(strPR_DEF_POST_MSGCLASS, _
strPR_DEF_POST_DISPLAYNAME)
propValues() = Array(formClass, formName)
Set pa = fld.PropertyAccessor
arrErrors = pa.SetProperties(propNames, propValues)
If Not (IsEmpty(arrErrors)) Then
'Examine the arrErrors array to determine if any
'elements contain errors
For i = LBound(arrErrors) To UBound(arrErrors)
'Examine the type of the element
If IsError(arrErrors(i)) Then
Debug.Print (CVErr(arrErrors(i)))
End If
Next
End If

End If
Set pa = Nothing
End Sub

Alternatively, if your add-in creates the folder, then you could deploy it
by including a .pst file as a project resource, with the folder in that
file, already prepopulated with the desired properties. Your code would
simply copy the folder to the user's existing folder hierarchy.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Fidget Brain

i did not realise that certain MAPI properties would not be exposed in the
..NET model and that I would have to use the PropertyAcessor to get/set them.
thanks for that info. I am new to MAPI and have had a cursory look through
the documentation on MSDN. however i could see no reference to the schemas
you mention to which define these properties e.g.
"http://schemas.microsoft.com/mapi/proptag/0x36E5001E". is there a place
which maps these schemas against the properties? thanks

You'll have to settle for doing it manually at present. There apparently is
a bug in Beta 2 related to using PropertyAccessor to set folder properties.
Otherwise, you'd be able to use something like (VBA prototype):

Sub SetDefaultFormFolder(fld As Outlook.Folder, _
formClass As String, formName As String)
Dim pa As Outlook.PropertyAccessor
Dim propNames()
Dim propValues()
Dim arrErrors()
strPR_DEF_POST_MSGCLASS = _
"http://schemas.microsoft.com/mapi/proptag/0x36E5001E"
strPR_DEF_POST_DISPLAYNAME = _
"http://schemas.microsoft.com/mapi/proptag/0x36E6001E"
'On Error Resume Next

If Not fld Is Nothing Then
propNames() = Array(strPR_DEF_POST_MSGCLASS, _
strPR_DEF_POST_DISPLAYNAME)
propValues() = Array(formClass, formName)
Set pa = fld.PropertyAccessor
arrErrors = pa.SetProperties(propNames, propValues)
If Not (IsEmpty(arrErrors)) Then
'Examine the arrErrors array to determine if any
'elements contain errors
For i = LBound(arrErrors) To UBound(arrErrors)
'Examine the type of the element
If IsError(arrErrors(i)) Then
Debug.Print (CVErr(arrErrors(i)))
End If
Next
End If

End If
Set pa = Nothing
End Sub

Alternatively, if your add-in creates the folder, then you could deploy it
by including a .pst file as a project resource, with the folder in that
file, already prepopulated with the desired properties. Your code would
simply copy the folder to the user's existing folder hierarchy.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

The easiest way is to use Outlook Spy to look them up. MAPI Editor (mfcmapi.exe) is free and has similar features, but it's not as easy as OL Spy.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top