Announcement

Collapse
No announcement yet.

Script import into Exchange Public Folder

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script import into Exchange Public Folder

    Hi all

    We have a spreadsheet (can be a csv) which has a timetable of 5 members of staff working pattern. We want this to be imported into a calendar which lives in the public folders. Has anyone got any example code of how to script the adding of a calendar item to the publi folders?

    Thanks

    Chris
    Server 2000 MCP
    Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

  • #2
    Re: Script import into Exchange Public Folder

    I found the answer on www.outlookcode.com:

    I have adapted it slightly and have yet to add the csv import code but here is the business part:

    Code:
    Imports System
    Imports System.IO
    Imports Microsoft.Office.Interop
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
        Function GetFolder(ByVal strPublicFolder As String) As Outlook.MAPIFolder
            Dim objOutlook As Outlook._Application
            objOutlook = New Outlook.Application
            Dim strFolderPath As String, arrFolders As Array
    
            Dim objNS As Outlook.NameSpace = objOutlook.Session
            Dim objFolder As Outlook.MAPIFolder, I As Integer
    
            On Error Resume Next
            strFolderPath = Replace(strPublicFolder, "/", "\")
            arrFolders = Split(strFolderPath, "\")
            objFolder = objNS.Folders.Item(arrFolders(0))
            If Not objFolder Is Nothing Then
                For I = 1 To UBound(arrFolders)
                    objFolder = objFolder.Folders(arrFolders(I))
                    If objFolder Is Nothing Then
                        Exit For
                    End If
                Next
            End If
            Return objFolder
        End Function
    
        Private Sub btn_addapp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_addapp.Click
            
            Dim objOutLook As Outlook._Application
            Dim strPublicFolder As String, fldFolder As String, olAppoint As Outlook.AppointmentItem
            Dim objFolder As Outlook.MAPIFolder
            objOutLook = New Outlook.Application
    
            strPublicFolder = "Public Folders\All Public Folders\CP Test"
            objFolder = GetFolder(strPublicFolder)
            'MsgBox("fldFolder = " & objFolder.Name)
            olAppoint = objFolder.Items.Add()
            With olAppoint
                .Start = "12/12/2007 16:00"
                .End = "12/12/2007 16:30"
                .Subject = "Test"
                .Save()
            End With
        End Sub
    Server 2000 MCP
    Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    Comment


    • #3
      Re: Script import into Exchange Public Folder

      Do you know how to add members to the folder with specific permissions? I've been trying to figure out a way to do this for a while. I've only seen posts saying to use CDO 1.21 and the ACL.dll COM component, but I have no idea what to do with that...

      Comment


      • #4
        Re: Script import into Exchange Public Folder

        Originally posted by ekrengel View Post
        Do you know how to add members to the folder with specific permissions? I've been trying to figure out a way to do this for a while. I've only seen posts saying to use CDO 1.21 and the ACL.dll COM component, but I have no idea what to do with that...
        From what i can see, this has nothing to do the original thread. Please start another.
        Server 2000 MCP
        Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

        ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

        Comment

        Working...
        X