From Outlook to Access

C

Clouds®

Hi all,

I have an Access-database that contains filenames and some info on each of
the files.
There are forms to add and lookup records.

Now I'd like to 'import' attachments from Outlook to this database.
In an ideal situation it would be like this:
- In Outlook the user starts the macro when one or more emails selected.
- If there is more than one attachment, a list pops up where the user can
choose which file(s) to process.
- A form pops up where the user has to enter some info for each selected
file.
- The info is written to the Access database, and the attachments are saved
in a predefined folder, but the filenames are based on the info the user
just entered.

The part where the list of attachments is shown etc. I think I can manage
that (partly done).
But how do I get the info to be stored in Access?

TIA for your help!
 
P

Peter

I'm not greatly familiar with the actual programming of this, but it seems that it would work something like this:
Add a reference to MS Access to your Outlook project (Tools->References, find and check Microsoft Access), Dim an object as Access.Application, and use that object to open, read from and write to your Access database.
Then use Outlook objects to extract the attachment(s) from the selected e-mail(s) and save them:

Sub SaveAttachments()

Dim OpenFolder As Explorer
Dim SelectedEmails As Selection
Dim i As Integer
Dim Atchments As Attachments
Dim Atchment As Attachment

Set OpenFolder = Application.ActiveExplorer

Set SelectedEmails = OpenFolder.Selection

For i = 1 To SelectedEmails.Count
Set Atchments = SelectedEmails(i).Attachments
For Each Atchment In Atchments
'... do stuff with the attachment, such as Atchment.SaveAsFile
Next
Next

Set Atchment = Nothing
Set Atchments = Nothing
Set SelectedEmails = Nothing
Set OpenFolder = Nothing

End Sub

My $0.02,

-Peter
 

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