I have found this rather old code to search my Outlook folder and add the name of the folder to an unbound text box on a form.
What I need to be able to accomplish is to actually store the link in the field to the folder, preferably using the folder name as the link name as opposed to the full path to the Outlook folder.
Here is the code (I plan on cleaning this up):
***********************
Private Sub Command3_Click()
Call SelectFolder
End Sub
Function SelectFolder()
'Created by Helen Feddema 8-25-2000
'Last modified 8-26-2000
On Error GoTo ErrorHandler
Set appOutlook = CreateObject("Outlook.Application")
Set nms = appOutlook.GetNamespace("MAPI")
SelectContactFolder:
Set pfld = nms.PickFolder
Debug.Print "Default item type: " & pfld.DefaultItemType
If pfld.DefaultItemType <> olMailItem Then
MsgBox "Please select a Mail folder"
GoTo SelectContactFolder
End If
Forms![Form1].SetFocus
Me![FolderName].Value = pfld.Name
ErrorHandlerExit:
Exit Function
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Function
*******************
I do not have a need to store the actual emails in the database, only a link to the folder to make quick reference to them. We generally have an individual Outlook folder for each of our projects. Once the project is complete, we convert the emails to a PDF and delete from Outlook. I already have the functionality to link files to the projects from the hard drive.
As always, any help is appreciated.
What I need to be able to accomplish is to actually store the link in the field to the folder, preferably using the folder name as the link name as opposed to the full path to the Outlook folder.
Here is the code (I plan on cleaning this up):
***********************
Private Sub Command3_Click()
Call SelectFolder
End Sub
Function SelectFolder()
'Created by Helen Feddema 8-25-2000
'Last modified 8-26-2000
On Error GoTo ErrorHandler
Set appOutlook = CreateObject("Outlook.Application")
Set nms = appOutlook.GetNamespace("MAPI")
SelectContactFolder:
Set pfld = nms.PickFolder
Debug.Print "Default item type: " & pfld.DefaultItemType
If pfld.DefaultItemType <> olMailItem Then
MsgBox "Please select a Mail folder"
GoTo SelectContactFolder
End If
Forms![Form1].SetFocus
Me![FolderName].Value = pfld.Name
ErrorHandlerExit:
Exit Function
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End Function
*******************
I do not have a need to store the actual emails in the database, only a link to the folder to make quick reference to them. We generally have an individual Outlook folder for each of our projects. Once the project is complete, we convert the emails to a PDF and delete from Outlook. I already have the functionality to link files to the projects from the hard drive.
As always, any help is appreciated.