Does anyone know how to program Outlook without any reference to MAPI?
All examples I found use MAPI one way or another.
Here's code I use to add public folder. Can it be cone without MAPI?
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim strFolderPath As String
Dim I As Long
Private Sub cmdAdd_Click()
On Error Resume Next
strFolderPath = "Public Folders\All Public Folders\Jim106"
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If arrFolders(I) = "Jim106" Then
objFolder.Folders.Add "AlanContacts", olFolderContacts
ReDim arrFolders(I + 2)
arrFolders(I + 1) = "AlanContacts"
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I + 1))
End If
If objFolder Is Nothing Then
Exit For
End If
Next I
End If
Set objFolder = Nothing
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
strFolderPath = "Public Folders\All Public Folders\Jim106"
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If arrFolders(I) = "Jim106" Then
objFolder.Folders.Add "AlanCalendar", olFolderCalendar
ReDim arrFolders(I + 2)
arrFolders(I + 1) = "AlanCalendar"
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I + 1))
End If
If objFolder Is Nothing Then
Exit For
End If
Next I
End If
Set objFolder = Nothing
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
Thanks,
Alan
All examples I found use MAPI one way or another.
Here's code I use to add public folder. Can it be cone without MAPI?
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim strFolderPath As String
Dim I As Long
Private Sub cmdAdd_Click()
On Error Resume Next
strFolderPath = "Public Folders\All Public Folders\Jim106"
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If arrFolders(I) = "Jim106" Then
objFolder.Folders.Add "AlanContacts", olFolderContacts
ReDim arrFolders(I + 2)
arrFolders(I + 1) = "AlanContacts"
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I + 1))
End If
If objFolder Is Nothing Then
Exit For
End If
Next I
End If
Set objFolder = Nothing
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
strFolderPath = "Public Folders\All Public Folders\Jim106"
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If arrFolders(I) = "Jim106" Then
objFolder.Folders.Add "AlanCalendar", olFolderCalendar
ReDim arrFolders(I + 2)
arrFolders(I + 1) = "AlanCalendar"
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I + 1))
End If
If objFolder Is Nothing Then
Exit For
End If
Next I
End If
Set objFolder = Nothing
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
Thanks,
Alan