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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proper Coding To Link to Outlook Folder

Status
Not open for further replies.

pjd218

Technical User
Apr 14, 2008
40
US
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.

 
did you know You can link the outlook folder as a linked table?

HTH

Remember amateurs built the ark - professionals built the Titanic

[flush]
 
Yep.

We maintain separate Outlook folders for each project we work on so linking the tables would be a bit problematic. It would also require creating additional forms to view the emails.

Once a project is complete, we save the emails to a PDF and delete the folder, hence the reason for just linking to the folder instead of creating a new table.

Linking would create additional overhead on the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top