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

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)
 
J

John Riddle

This is more of an Outlook question than Exchange, but if you're looking to
get a list of open email items, you have to loop through the Inspectors
collection:

Dim myInspectors As Outlook.Inspectors
Dim myInspector As Outlook.Inspector

For Each myInspector in myInspectors
Set myMail = myInspector.CurrentItem
For i = 1 to myMail.Attachments.Count
msgBox myMail.Attachments.Item(1).FileName
Next
Set myMail = Nothing
Next
Set myInspector = Nothing
Set myInspectors = Nothing

This shows how to enumerate through the open inspectors, of coarse you'd
have to modify the code to do something like populate a listbox with the
items or process them in some way.

John
 
P

Phil Hollingworth

Hi John

Thanks for your response.

Your suggestion did work and I was able to access the Inspectors collection
to identify all the open email windows. However, I was unable to get full
access to these windows to insert attachments.

Any other suggestions?

Kind regards

Phil H.
(e-mail address removed)
 
K

Ken Slovak - [MVP - Outlook]

Each Inspector has a CurrentItem property. That is what would have an
Attachments collection:

Dim oMail As Outlook.MailItem
Dim colAttach As Outlook.Attachments

Set oMail = oInspector.CurrentItem
Set colAttach = oMail.Attachments
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top