![]() |
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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Anyone know how to create public calendars in vb or vbscript? I was
able to create public folders but not calendars. cyk. |
Ads |
#2
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |