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_PublicFolder 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/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_PublicFolder"
cComputerName = "."
cPublicFolderPath = "/foldertomailenable/"
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _
cComputerName&"/"&cWMINameSpace
Set objWMIServices = GetObject(strWinMgmts)
Set objPubInstances = objWMIServices.ExecQuery ("Select * From
Exchange_PublicFolder Where Path='" & cPublicFolderPath & "'")
For Each objExchange_PublicFolder in objPubInstances
wscript.echo objExchange_PublicFolder.ADProxyPath
objExchange_PublicFolder.IsMailEnabled = true
objExchange_PublicFolder.Put_()
if not isnull(objExchange_PublicFolder.ADProxyPath) then
set objfolder = getobject("LDAP://<GUID=" &
transposeGuid(objExchange_PublicFolder.ADProxyPath ) & ">")
wscript.echo objfolder.name
end if
Next
Function transposeGuid(guid)
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**************@TK2MSFTNGP14.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.Management.ManagementObject instmailbox in
queryCollection )
{
instmailbox["IsMailEnabled"] = 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 distinguishedName 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