Trying to open a saved mail msg using access

  • Thread starter Thread starter John Brit
  • Start date Start date
J

John Brit

Hi Folks,

I have a list box that contains a list of mail messages
(that have been saved).

Does anyone know how I can double click on a message and
open it using outlook?

Regards
John
 
Sorry Sue I should have been more specific.

I have a bunch of .msg files in a directory. I have used a
list box to see the files in the directory but would like
to double click on an item in the list box and open
that .msg file using outlook (or is it word configured to
edit .msg files I'm not sure).

Any help would be very much appreciated.
 
Thanks Sue. You're a star
-----Original Message-----
You can run any file in its default application with Windows Script Host:

Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run <your file name>

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers






.
 
You can run any file in its default application with Windows Script Host:

Set objWSHShell = CreateObject("WScript.Shell")
objWSHShell.Run <your file name>

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Hi Sue,

Sorry to be a pain but your suggestion didn't work. I also
forgot to say that I am working using Outlook (and Access)
97.
 
What precisely didn't work? Do you have Windows Script Host installed?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I think not. If it is the network supervisor hasn't let me
have access to it.

My main problem is that I've never used outlook for
anything other than the basics before. So while I am
familiar with VBA I just don't know what I'm doing wrong.

I started like this

Dim oApp As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder

Set oNS = oApp.GetNamespace("MAPI")
oNS.Logon , , True, True

but I am a little lost now. I don't know how to refer to
the folder where the .msg files are saved to and I don't
know how to display the mail item when I double click on
it in my list box.

The full path and file name are known from te list box by
the way.
 
The code below is for working with folders in Outlook. Your .msg items are
not in Outlook folders but in system file folders. Therefore, you need to be
using the FileSystemObject library (see
http://www.outlookcode.com/d/vbscript.htm for links to tutorial and other
resources) or the file-handling features in the core VBA library.

But if you already have the file path and file name, why are you even
worrying about the folder? You already have all the information available.

To open a file whose name is displayed in a list box, you would need to
write code for the list box's DblClick event to do something with the file
path+filename. If you can't use WSH, then you'd have to use Outlook's
Application.CreateItemFromTemplate method, which may not be satisfactory, as
it creates a copy of the original .msg file.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top