473,749 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 LegacyExchangeD N on the AD object. I am able to get the
distinguishedNa me property by using a DirectorySearch er (C#) that looks for
objects with a LegacyExchangeD N property matching the TargetAddress. Are
there any problems with this approach?

Morten

"Glen Scales [MVP]" <gs*****@outloo kexchange.com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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_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


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

Cheers
Glen

"Morten" <mo************ **@hotmail.com> wrote in message
news:ut******** ******@TK2MSFTN GP09.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 LegacyExchangeD N on the AD object. I am able to get the
distinguishedNa me property by using a DirectorySearch er (C#) that looks
for objects with a LegacyExchangeD N property matching the TargetAddress.
Are there any problems with this approach?

Morten

"Glen Scales [MVP]" <gs*****@outloo kexchange.com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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_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



Nov 17 '05 #4

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

Similar topics

2
1727
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 want to specify in window.open() in page1 when it loads page2. <script type="text/javascript"> function window_onload() { }
1
1290
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+)> <!ELEMENT Camp (name, campcode?, ContactPhone, ContactPhone?, Activity+)>
1
1764
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: ### begin script ### (located in ../faa/faa_script.xyz) ### init script
0
3458
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 -U username to specify username which actually doesn't work for me, I still get prompted for username, but there is nothing to specify password. Is there anyway of going around this? I need to automate everything
6
6365
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
1778
by: RA | last post by:
Hi Is there a way to specify where the custom EventLog file will be created? Thanks
3
2600
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 action, seems no way to specify more than one action there, I might be able to use a batch file for it but just whish there is something better. Guess I must have missed something. any info is appreciated. Thanks In Advance!
2
4495
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 best for evenness?
0
1071
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 network card). Is there a way to specify the Web Site to deploy my web application ? By default, It's seem to deploy on the Default Web site. I know I can specify the Port but on my case It's the same... Is there a way to specify the Web Site on...
3
2601
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 mirrored set of really large flash drives. The workstations will write to their specific standard .evt files. I need to be able to start EventViewer and specify which workstations's logs to go view at startup. Is this possible w/o creating my own...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.