Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming Outlook -- MAPI 1

Status
Not open for further replies.

alan12345

IS-IT--Management
Dec 20, 2004
56
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top