Can Outlook.Application be used to control open message windows?

  • Thread starter Thread starter Phil Hollingworth
  • Start date Start date
P

Phil Hollingworth

Hi

We have a VFP 8 CRM application which - amongst other things - stores links
for any client to any document relating to them on our file server. When you
go into a client record you can see instantly if there are any documents on
file relating to them and it is straight forward to add a new file to a
record if we received something via email for instance.

The physical location of the file is not too important to our users as they
simply double click any file they want to view and the file is executed in
the shell object to open it's associated viewer.

The problem I am currently trying to solve is when a user wants to attach
one or more files relating to a client to an email. Currently they have to
manually create the email and more irritatingly they then have manually
navigate to all the files they want to attach.

What I would like to be code would be some way for the user to initially
create the email as usual and then, from the client record on the
application, select the files they want to send and click a button which
some how attaches the files from their various locations into the email the
user has created.

I thought an easy way to do this would be to access some kind of object
collection in the Outlook.Application model to provide the user with a list
of the open email windows and their subjects which should enable the user
which window / message they want their files attached to.

However I cannot find any way of accessing anything other than the main
outlook window.

Does anyone have any ideas how this could be achieved?

Thanks in advance!!

Phil H
(e-mail address removed)
 
Phil, you can use the inspectors collection to do what you are asking. Here
is a simple subroutine that will list subjects for all open mail items.

Sub ListOpenMailItems()
Dim outapp As New Outlook.Application
Dim isps As Outlook.Inspectors
Dim isp As Outlook.Inspector

'get collection of currently open items
Set isps = outapp.Inspectors
For Each isp In isps
'check the class and only list mail items
If isp.CurrentItem.Class = OlObjectClass.olMail Then
Debug.Print isp.CurrentItem.Subject
End If
Next
End Sub


--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
 
Back
Top