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

Linking to public folders on an exchange server

Status
Not open for further replies.

thebeardedladie

Technical User
Joined
Aug 24, 2000
Messages
10
Location
GB
Hi,

I am new to access but am learning all the time ;-). I recently found how to link a public folder on an exchange server to a table that displays the messages. (using the download from microsofts website)

This solution is not very efficient. I would like to be able to put links in each record or on forms that would open Outlook and browse automatically to the correct folder. I'm using access 97 but we will soon be upgrading to 2000 (it really has to work in both)

Is this possible?

Thanks in advance
Doug
 
Doug,

I'm not sure what you mean by "put links in each record or on forms that would open Outlook and browse automatically to the correct folder"

What records are you referring to? How would you know what folder you want to browse to?

Kathryn
 
Sorry I was not very clear.

I am making a database that contains information on various engineering software programs. For some of the software programs we have public folders set up on an exchange server that contain additional information about the software a long with updates and patches (attached to posts).

I would like to be able to access this information from within the database. The best solution would be to have a button on a form, that, when clicked would open Outlook at the correct public folder that relates to the current record displayed in the form.

Doug
 
This you can do, pretty easily as a matter of fact.

You will create a reference to Outlook and use it to open Outlook and make it visible and to make your folder the current folder.

Something like this

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myOlApp.ActiveExplorer.CurrentFolder = _
myNameSpace.Folders("YourFolderName")


You will have to make the Outlook instance visible. I'm not sure if it's

myOlApp.visible=true

but I think it is.

Give it a try and see what happens.



 
Thanks for the code, I am afraid this will be the first VBA stuff I've tried. I will do my best to use what you have given me but if you could explain in more detail it would be greatly appreciated.

My questions are as basic as:

Do you put the code under an event procedure with the button?

If you don't have the time to go into this detail thanks for the code you suggested, I'll have to contact a friend of a friend for help.

Thanks
 
Yes, but the cool thing is that Access will do most of the work for you. Before you add the button to the form, make sure that the wizard button is chosen (that's the button in the Toolbox with the wand and fairy dust).

Then choose the command button, put it on your form and the wizard will start. Read the description of what the wizard does then choose Application from the left pane and Word from the right. You will get something like:

***********
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
***************

Change Word.Application to Outlook Application, then add another Dim statement and the code from above to get


************
Dim oApp As Object
Dim myNameSpace as object

Set oApp = CreateObject("Word.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myOlApp.ActiveExplorer.CurrentFolder = _
myNameSpace.Folders("YourFolderName")
oApp.Visible = True
*************

Good luck.
 
I think i have done as you said, but when I tried to run it I got an error message saying "Compile error can't find project or library"
The code looks like this now

******************
Private Sub publicfolder_Click()
On Error GoTo Err_publicfolder_Click

Dim oApp As Object
Dim myNameSpace As Object

Set oApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myOlApp.ActiveExplorer.CurrentFolder = _
myNameSpace.Folders("\Corporate Development")
oApp.Visible = True

Exit_publicfolder_Click:
Exit Sub

Err_publicfolder_Click:
MsgBox Err.Description
Resume Exit_publicfolder_Click

End Sub

****************

I think this is how you suggested it?
 
Oops, I forgot to mention that you need to set a reference to Outlook. From your code window, choose Tools...References and scroll until you get to MS Outlook. Check the box and that should do it (until you get your next error!)

Welcome to the wonderful world of coding.

 
I think I have problems! The only refrences I have available for Outlook are

Microsoft Outlook 8.0 object library
Microsoft Exchange event service conf... (not strictly outlook but could be relevant?)

Could I get the .olb from microsoft or something?

thanks
 
You want the Microsoft Outlook 8.0 object library.

 
I still get the same message I mentioned before, I did try it before the last post and it didn't work. I tried again just now and it still wouldn't work.

Doug
 
OK we need to set a breakpoint. Open the code window and click in the left margin of the first executable line, which is "Set oApp = CreateObject("Outlook.Application")" If you are clicking in the right place, the line will turn to dark red (that's the color on my machine).

Now run the code again. The code will stop there. Then you will press F8 to go to the next line. This will enable you to see exactly what code is causing the error.

 
I'm not at work at the moment so will have to try again tommorow, but as far as I can remeber when the code runs it highlights:

Private Sub publicfolder_Click()

in yellow and

Set myNameSpace = ***myOlApp***.GetNameSpace("MAPI")

the myOLApp which is between the asterix is also in yellow.

this could be the problem?
 
Yep, that's the problem. Post the entire procedure and I'll take a look.
 
Because I'm at home now the best I can do is what i posted before:

******************
Private Sub publicfolder_Click()
On Error GoTo Err_publicfolder_Click

Dim oApp As Object
Dim myNameSpace As Object

Set oApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myOlApp.ActiveExplorer.CurrentFolder = _
myNameSpace.Folders("\Corporate Development")
oApp.Visible = True

Exit_publicfolder_Click:
Exit Sub

Err_publicfolder_Click:
MsgBox Err.Description
Resume Exit_publicfolder_Click

End Sub

****************

If this isn't enough I will hopefully have the database with me by about 9.00am gmt tommorrow, I'll be able to post what ever you need then.

I have to say now that i'm incredibly gratefull for all your help, this is going to earn me so many brownie points! (and make the database very productive)

thanks again
 
Good morning! As I feared, it is just a silly typo. We dim the variable as oApp, but then we refer to it as myolApp. I have backed up a bit and decided that we need to take this step by step.

This code opens Outlook to the user's inbox

**********
Private Sub publicfolder_Click()
On Error GoTo Err_publicfolder_Click

Dim myolApp As Object
Dim myNameSpace As Object
Dim myFolder As Object

Set myolApp = CreateObject("Outlook.Application")
' myolApp.Visible = True

Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
myFolder.Display

Exit_publicfolder_Click:
Exit Sub

Err_publicfolder_Click:
MsgBox Err.Description
Resume Exit_publicfolder_Click



End Sub
*************

Make sure that this code works for you. Now we have to modify it to open to the specific folder you want. Can you tell me what kind of items your corporate development folder contains: Mail Items, Notes, Appointments?

 
Hi, sorry its taken a while to respond, my connection went down for some reason.

The database wasn't e mailed to me so I have created a replica on my computer at home.

I have Outlook but it hasn't got the public folders. I will be back in work on tuesday to do every thing properly.

But for now, the new code has problems with the line

Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)

The "(olFolderInbox)" is high lighted in yellow, a box says can't find object or library. This could be as i do not have Outlook configured as I don't use it.

In answer to your other question the public folders are divided into many other folders (corporate development was only one I choose for an example) in these folders there are posts, like you would post to a newsgroup. I think they are mail items. All I would want to do was browse to a specific folder, I don't need to specify particular posts/mail Items.

doug
 
Hi Guys,

I am trying to do something similar to this, We have a lot of mails stored in the Public Folders, Now I need to write a VB program and take a list of all the Folder and Sub Folders in the Microsoft Exchange - Public Folders.

How do I do it, Can someone help me with sample code.

Task 2
I also have another task, I need to read all the mails and write a Word document for each sub folder with the contents.

Can someone help me how I could connect to public folders, like olFolderInbox Constant, what should I have for public Folder.


Regards
Krushna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top