Once the Proxy object in created in Active Directory (i think its the RUS)
will then stamp the folder with the objectGuid of the Active Directory
object. You can get this information via the ADProxypath property in the WMI
Exchange_Public Folder class. There are two issues with this though firstly
it doesn't happen instantaneously after you issue the put command and also
the GUID you retrieve via WMI needs to be transposed. You can then use the
GUID to bind to the object in Active Directory eg
http://msdn.microsoft.com/library/de...ty_methods.asp.
eg something like this will work as long as you wait for the ADProxypath to
get updated.
Dim cComputerName
Const cWMINameSpace = "root/MicrosoftExchan geV2"
Const cWMIInstance = "Exchange_Publi cFolder"
cComputerName = "."
cPublicFolderPa th = "/foldertomailena ble/"
strWinMgmts = "winmgmts:{impe rsonationLevel= impersonate}!//"& _
cComputerName&"/"&cWMINameS pace
Set objWMIServices = GetObject(strWi nMgmts)
Set objPubInstances = objWMIServices. ExecQuery ("Select * From
Exchange_Public Folder Where Path='" & cPublicFolderPa th & "'")
For Each objExchange_Pub licFolder in objPubInstances
wscript.echo objExchange_Pub licFolder.ADPro xyPath
objExchange_Pub licFolder.IsMai lEnabled = true
objExchange_Pub licFolder.Put_( )
if not isnull(objExcha nge_PublicFolde r.ADProxyPath) then
set objfolder = getobject("LDAP ://<GUID=" &
transposeGuid(o bjExchange_Publ icFolder.ADProx yPath) & ">")
wscript.echo objfolder.name
end if
Next
Function transposeGuid(g uid)
transposeGuid = mid(guid,8,2) & mid(guid,6,2) & mid(guid,4,2) _
& mid(guid,2,2) & mid(guid,13,2) & mid(guid,11,2) _
& mid(guid,18,2) & mid(guid,16,2) & mid(guid,21,4) _
& mid(guid,26,12)
end function
You may however be better of just using CDOEXM and the IMailRecipient
Interface to do this using the folder path.
Cheers
Glen
"Morten" <mo************ **@hotmail.com> wrote in message
news:u2******** ******@TK2MSFTN GP14.phx.gbl...
Hi!
I'm trying to manage public folders using C#. I have found some code that
allows me to mail enable a folder:
foreach( System.Manageme nt.ManagementOb ject instmailbox in
queryCollection )
{
instmailbox["IsMailEnab led"] = true;
instmailbox.Put ();
}
This works fine. However I can't figure out how to actually specify the
mail address of the public folder. Things would of course be easy if I was
able to retrieve the distinguished name of the folder in AD but the
problem is that if 2 folders have the same name then a large random number
is added to the distinguished name of the folder - so I'm unable to guess
what the distinguishedNa me of the folder is. Can I somehow look up the
Exchange object in AD?
I hope someone can help because this is driving me crazy...
Morten