|
|
|
date: Thu, 1 Dec 2005 21:06:59 -0500,
group: microsoft.public.exchange2000.development
back
Re: Programmatically Create Calendar Items in mailbox store
One way would be to use a combination of ADSI to work out what mailboxes are
on the server and then use CDOEX to create the appointment this code would
need to be run locally on the Exchange server your targeting because its
using Exoledb
Servername = "servername"
Set Person = CreateObject("CDO.Person")
set conn = createobject("ADODB.Connection")
set com = createobject("ADODB.Command")
Set iAdRootDSE = GetObject("LDAP://RootDSE")
strNameingContext = iAdRootDSE.Get("configurationNamingContext")
strDefaultNamingContext = iAdRootDSE.Get("defaultNamingContext")
Conn.Provider = "ADsDSOObject"
Conn.Open "ADs Provider"
svcQuery = "<LDAP://" & strNameingContext &
">;(&(objectCategory=msExchExchangeServer)(cn=" & Servername &
"));cn,name,legacyExchangeDN;subtree"
Com.ActiveConnection = Conn
Com.CommandText = svcQuery
Set Rs = Com.Execute
while not rs.eof
GALQueryFilter = "(&(&(&(&
(mailnickname=*)(!msExchHideFromAddressLists=TRUE)(|
(&(objectCategory=person) (objectClass=user)(msExchHomeServerName=" &
rs.fields("legacyExchangeDN") & ")) )))))"
strQuery = "<LDAP://" & strDefaultNamingContext & ">;" & GALQueryFilter &
";distinguishedName,mail;subtree"
com.Properties("Page Size") = 100
Com.CommandText = strQuery
Set Rs1 = Com.Execute
while not Rs1.eof
Person.DataSource.Open "Ldap://" & rs1.fields("distinguishedName")
Set Mailbox = Person.GetInterface("IMailbox")
call CreateAppointment(now(),dateadd("h",1,now()),"test
appointment","Meeting Room","Important",mailbox)
rs1.movenext
wend
rs.movenext
wend
rs.close
set conn = nothing
set com = nothing
wscript.echo "Done"
Function CreateAppointment(StartTime,EndTime,Subject,Location,TextBody,iMbx)
on error resume next
set iAppt = createobject("CDO.Appointment")
Set Conn = createobject("ADODB.Connection")
Conn.Provider = "ExOLEDB.DataSource"
'Set the appointment properties
With iAppt
.StartTime = StartTime
.EndTime = EndTime
.Subject = Subject
.Location = Location
.TextBody = TextBody
'Save the appointment
Conn.Open iMbx.BaseFolder
.DataSource.SaveToContainer iMbx.Calendar, Conn
End With
Set CreateAppointment = iAppt
Wscript.echo "Appointment Created in " & iMbx.Calendar
End Function
Cheers
Glen
"Siva" wrote in message
news:L4-dnXbBTsG3MRLeRVn-rA@comcast.com...
> Hi Guys -
> Is there a way to programmatically recurse a mailbox store and create a
> calendar entry for all the mailboxes in that store?
> Is there a 3rd party software that would do this?
>
> If it can be scripted, any samples or pointers? Thanks for your time...
>
date: Mon, 5 Dec 2005 10:30:20 +1100
author: Glen Scales [MVP]
Re: Programmatically Create Calendar Items in mailbox store
Thank you - Very much!
"Glen Scales [MVP]" wrote in message
news:uVtOzqS%23FHA.2320@TK2MSFTNGP11.phx.gbl...
> One way would be to use a combination of ADSI to work out what mailboxes
> are on the server and then use CDOEX to create the appointment this code
> would need to be run locally on the Exchange server your targeting because
> its using Exoledb
>
> Servername = "servername"
>
> Set Person = CreateObject("CDO.Person")
> set conn = createobject("ADODB.Connection")
> set com = createobject("ADODB.Command")
> Set iAdRootDSE = GetObject("LDAP://RootDSE")
> strNameingContext = iAdRootDSE.Get("configurationNamingContext")
> strDefaultNamingContext = iAdRootDSE.Get("defaultNamingContext")
> Conn.Provider = "ADsDSOObject"
> Conn.Open "ADs Provider"
> svcQuery = "<LDAP://" & strNameingContext &
> ">;(&(objectCategory=msExchExchangeServer)(cn=" & Servername &
> "));cn,name,legacyExchangeDN;subtree"
> Com.ActiveConnection = Conn
> Com.CommandText = svcQuery
> Set Rs = Com.Execute
> while not rs.eof
> GALQueryFilter = "(&(&(&(&
> (mailnickname=*)(!msExchHideFromAddressLists=TRUE)(|
> (&(objectCategory=person) (objectClass=user)(msExchHomeServerName=" &
> rs.fields("legacyExchangeDN") & ")) )))))"
> strQuery = "<LDAP://" & strDefaultNamingContext & ">;" & GALQueryFilter &
> ";distinguishedName,mail;subtree"
> com.Properties("Page Size") = 100
> Com.CommandText = strQuery
> Set Rs1 = Com.Execute
> while not Rs1.eof
> Person.DataSource.Open "Ldap://" & rs1.fields("distinguishedName")
> Set Mailbox = Person.GetInterface("IMailbox")
> call CreateAppointment(now(),dateadd("h",1,now()),"test
> appointment","Meeting Room","Important",mailbox)
> rs1.movenext
> wend
> rs.movenext
> wend
> rs.close
> set conn = nothing
> set com = nothing
> wscript.echo "Done"
>
>
>
> Function
> CreateAppointment(StartTime,EndTime,Subject,Location,TextBody,iMbx)
> on error resume next
> set iAppt = createobject("CDO.Appointment")
> Set Conn = createobject("ADODB.Connection")
> Conn.Provider = "ExOLEDB.DataSource"
>
> 'Set the appointment properties
> With iAppt
> .StartTime = StartTime
> .EndTime = EndTime
> .Subject = Subject
> .Location = Location
> .TextBody = TextBody
> 'Save the appointment
> Conn.Open iMbx.BaseFolder
> .DataSource.SaveToContainer iMbx.Calendar, Conn
> End With
> Set CreateAppointment = iAppt
> Wscript.echo "Appointment Created in " & iMbx.Calendar
> End Function
>
> Cheers
> Glen
>
> "Siva" wrote in message
> news:L4-dnXbBTsG3MRLeRVn-rA@comcast.com...
>> Hi Guys -
>> Is there a way to programmatically recurse a mailbox store and create a
>> calendar entry for all the mailboxes in that store?
>> Is there a 3rd party software that would do this?
>>
>> If it can be scripted, any samples or pointers? Thanks for your time...
>>
>
>
date: Mon, 5 Dec 2005 16:00:12 -0500
author: Siva
|
|