A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Creating public calendars in vb or vbscript.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 4th 06, 01:44 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default Creating public calendars in vb or vbscript.

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.

Ads
  #2  
Old July 4th 06, 05:20 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating public calendars in vb or vbscript.

If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.


  #3  
Old July 5th 06, 09:14 PM posted to microsoft.public.outlook.program_vba
cykill
external usenet poster
 
Posts: 6
Default Creating public calendars in vb or vbscript.

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.



  #4  
Old July 5th 06, 10:20 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating public calendars in vb or vbscript.

Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.




  #5  
Old July 5th 06, 11:57 PM posted to microsoft.public.outlook.program_vba
cykill
external usenet poster
 
Posts: 6
Default Creating public calendars in vb or vbscript.

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.





  #6  
Old July 6th 06, 10:56 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating public calendars in vb or vbscript.

Oh, you're using CDOEX. This forum is for the Outlook Object Model. But
here's a thread in the appropriate newsgroup that has a code sample you can
use:

http://groups.google.com/group/micro...4da572f789d012

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.






  #7  
Old July 7th 06, 05:17 AM posted to microsoft.public.outlook.program_vba
cykill
external usenet poster
 
Posts: 6
Default Creating public calendars in vb or vbscript.

thanks for that. but its pretty much the same thing as what i have
now, which is creating a public folder. i need to create public
calendars. it doesn't matter which method i use, outlook object or
cdoex, i just need to create public caledars programatically. any
ideas?



Eric wrote:
Oh, you're using CDOEX. This forum is for the Outlook Object Model. But
here's a thread in the appropriate newsgroup that has a code sample you can
use:

http://groups.google.com/group/micro...4da572f789d012

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.







  #8  
Old July 7th 06, 07:05 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating public calendars in vb or vbscript.

You have to specify the specific content class for a calendar with CDOEX:

urn:content-classes:calendarfolder:
http://msdn.microsoft.com/library/en...asp?frame=true

With the Outlook Object Model, you'd use:

Sub AddCalendarFolder()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

thanks for that. but its pretty much the same thing as what i have
now, which is creating a public folder. i need to create public
calendars. it doesn't matter which method i use, outlook object or
cdoex, i just need to create public caledars programatically. any
ideas?



Eric wrote:
Oh, you're using CDOEX. This forum is for the Outlook Object Model. But
here's a thread in the appropriate newsgroup that has a code sample you can
use:

http://groups.google.com/group/micro...4da572f789d012

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.








  #9  
Old July 7th 06, 07:33 PM posted to microsoft.public.outlook.program_vba
cykill
external usenet poster
 
Posts: 6
Default Creating public calendars in vb or vbscript.

Thanks. I've tried your example and upon compiling, I get
outlook.application, outlook.namespace, outlook.mapifolder not defined.
Under references, i've added cdo, cdoexm, mapi and outlook. what else
do I need?




Eric wrote:
You have to specify the specific content class for a calendar with CDOEX:

urn:content-classes:calendarfolder:
http://msdn.microsoft.com/library/en...asp?frame=true

With the Outlook Object Model, you'd use:

Sub AddCalendarFolder()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

thanks for that. but its pretty much the same thing as what i have
now, which is creating a public folder. i need to create public
calendars. it doesn't matter which method i use, outlook object or
cdoex, i just need to create public caledars programatically. any
ideas?



Eric wrote:
Oh, you're using CDOEX. This forum is for the Outlook Object Model. But
here's a thread in the appropriate newsgroup that has a code sample you can
use:

http://groups.google.com/group/micro...4da572f789d012

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.









  #10  
Old July 7th 06, 07:58 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Creating public calendars in vb or vbscript.

You can't mix and match the code! CDOEX is meant to run on the Exchange
Server, were Outlook shouldn't be installed so you wouldn't be able to use
the Outlook Object Model. What lead you to use CDOEX in the first place?
There's some background to your solution that I'm missing.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

Thanks. I've tried your example and upon compiling, I get
outlook.application, outlook.namespace, outlook.mapifolder not defined.
Under references, i've added cdo, cdoexm, mapi and outlook. what else
do I need?




Eric wrote:
You have to specify the specific content class for a calendar with CDOEX:

urn:content-classes:calendarfolder:
http://msdn.microsoft.com/library/en...asp?frame=true

With the Outlook Object Model, you'd use:

Sub AddCalendarFolder()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

thanks for that. but its pretty much the same thing as what i have
now, which is creating a public folder. i need to create public
calendars. it doesn't matter which method i use, outlook object or
cdoex, i just need to create public caledars programatically. any
ideas?



Eric wrote:
Oh, you're using CDOEX. This forum is for the Outlook Object Model. But
here's a thread in the appropriate newsgroup that has a code sample you can
use:

http://groups.google.com/group/micro...4da572f789d012

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

sorry, i'm new to vb. i don't quite understand. let say i want to
create a calendar called "Chicago", what would the code be like? below
is my code to create a public folder.


Dim objFolder As Object
Dim szConnString As String
Dim oSysInfo As ActiveDs.ADSystemInfo
Dim szDomainDNSName As String
Dim szStorageName As String

' Get the domain name.
oSysInfo = New ActiveDs.ADSystemInfo
szDomainDNSName = oSysInfo.DomainDNSName

' Get the storage name.
szStorageName = "file://./backofficestorage/" + szDomainDNSName
+ "/"

' Create the folder.
szConnString = szStorageName + "public folders/Conferences/" +
szFolderName

Try
objFolder = CreateObject("CDO.Folder")
Catch f As Exception
System.Console.WriteLine("Error Creating Folder Object")
End Try

'Set the folder properties.
Try
With objFolder
.Description = "Root folder for " + szFolderName
.ContentClass = "urn:content-classes:folder"

..Fields("http://schemas.microsoft.com/exchange/outlookfolderclass") =
"IPF.Folders"
.Fields.Update()
.DataSource.SaveTo(szConnString)
End With
Catch e As Exception
Exit Try
objFolder = Nothing
oSysInfo = Nothing
End Try



Eric wrote:
Bind it to the folder you want to create your folder under. Use:

NameSpace.GetDefaultFolder(18)

Where 18 is the constant number for
olDefaultFolders.olPublicFoldersAllPublicFolders. This will give you a top
level folder, and you can use myFolder = MAPIFolder.Folders("FolderName")
ad-infinitum to traverse the hierarchy to get a specific folder.

You can also use a function like this to retrieve a MAPIFolder object if you
know the full path:

'************************************************* *****************************
'Custom procedu OpenMAPIFolder(ByVal strPath)
'Purpose: Return a MAPIFolder from Path argument
'Returns: MAPIFolder object
'************************************************* *****************************
Function OpenMAPIFolder(ByVal strPath) As Outlook.MAPIFolder
On Error Resume Next

Dim objFldr As MAPIFolder
Dim strDir As String
Dim strName As String
Dim i As Integer
If Left(strPath, Len("\")) = "\" Then
strPath = Mid(strPath, Len("\") + 1)
Else
Set objFldr = Application.ActiveExplorer.CurrentFolder
End If
While strPath ""
i = InStr(strPath, "\")
If i Then
strDir = Left(strPath, i - 1)
strPath = Mid(strPath, i + Len("\"))
Else
strDir = strPath
strPath = ""
End If
If objFldr Is Nothing Then
Set objFldr = Application.GetNamespace("MAPI").Folders(strDir)
On Error GoTo 0
Else
Set objFldr = objFldr.Folders(strDir)
End If
Wend
Set OpenMAPIFolder = objFldr
End Function

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cykill" wrote:

What should "myFolder" be bound to in your example?


Eric wrote:
If you don't specify the folder type with the Folders.Add method, it defaults
to the same type as the parent folder. Use the olDefaultFolders enumeration;
with olDefaultFolderCalendar, you need to use 9 in vbscript:

Set myNewFolder = myFolder.Folders.Add("My Public Calendar", 9)

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


" wrote:

Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars.

cyk.










 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Public calendars jmorc Outlook - Calandaring 4 September 15th 06 08:01 PM
Calendars in Public Folders KimTxRx Outlook - Calandaring 0 May 18th 06 08:39 PM
Creating a Calendar in Exchange 5.5 Public Folders...Rights error. Chris Stephens Outlook - Calandaring 1 May 4th 06 03:32 PM
Help with importing a creating contact list using vbscript John Connor Outlook - Using Contacts 1 April 27th 06 09:11 AM
Public Calendars Nikki Outlook - Calandaring 3 February 24th 06 10:06 PM


All times are GMT +1. The time now is 08:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.