473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Specify E-mail address for public folder

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
Nov 17 '05 #1
3 1990
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

Nov 17 '05 #2
Hi!

Thanks for your reply. It seems to me that I can use the TargetAddress
property instead of the ADProxypath. As far as I can see this proprety
corresponds to the LegacyExchangeDN on the AD object. I am able to get the
distinguishedName property by using a DirectorySearcher (C#) that looks for
objects with a LegacyExchangeDN property matching the TargetAddress. Are
there any problems with this approach?

Morten

"Glen Scales [MVP]" <gs*****@outlookexchange.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
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


Nov 17 '05 #3
I can't see any problems with that method the LegacyExchangeDN should be
unique so it should work fine.

Cheers
Glen

"Morten" <mo**************@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP09.phx.gbl...
Hi!

Thanks for your reply. It seems to me that I can use the TargetAddress
property instead of the ADProxypath. As far as I can see this proprety
corresponds to the LegacyExchangeDN on the AD object. I am able to get the
distinguishedName property by using a DirectorySearcher (C#) that looks
for objects with a LegacyExchangeDN property matching the TargetAddress.
Are there any problems with this approach?

Morten

"Glen Scales [MVP]" <gs*****@outlookexchange.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
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



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
I have a page1 that opens a window called page2. I want page2 doesn't have title bar, tool bar, address bar. Is it possible to specify in javascript function window_onload() in page2? I don't...
1
by: unwiseone | last post by:
Hello, Does any know how to specify a value of a DTD element? For example, here's an external DTD that I have: ======================================= <!ELEMENT summercamps (Camp+)>...
1
by: scooterm | last post by:
### Background In it is possible to specify any special and arbitrary directory (or set of directories) to use as a source for custom, user-designed modules. For example, one can do: ###...
0
by: N.K. | last post by:
Hello, I'm doing automated database dump and want to be able to specify Username and Passowrd in my shell script for pg_dump. When I do man pg_dump there are no options for password. There is...
6
by: Hype | last post by:
Hi, How can we specify the package names for sql stored procedures instead of system generated names ? (Db2 V8.2 on Windows.) thanks.....
1
by: RA | last post by:
Hi Is there a way to specify where the custom EventLog file will be created? Thanks
3
by: Polaris | last post by:
Hi: I'm using VC 7.1. I like to have multiple actions taken after a build is complete. For example, I'd like to copy the files into multiple directories. But so far I can only specify ONE...
2
by: Tony | last post by:
Yes, I need to specify a font type so that the characters will be evenly spaced when I write to a tab delimited text file. So how does one specify a font type to write/print and which font is...
0
by: sylvain | last post by:
I create a deployment kit with VS and I want to specify a Web Site different then the Default Web Site. There are two Web Site on our Web Server and they are using the same Port (two different...
3
by: =?Utf-8?B?Q0QuU21hbGxleQ==?= | last post by:
Is there a command line switch available for the EventViewer which will allow me to specify which directory to view the available logs from? I will have multiple workstations writing to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.