By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Opening Outlook original message from a linked Outlook mailbox

P: 4
I successfully linked a mail Outlook folder into an Access database. Now I'm trying, if possible, to open the selected email messagge. I do not need to create a new message starting from access or to import messages information into a table, I just need to view the original message in its Outlook format.
I'm aware that there is'nt any unique record ID in Access table linked to Outlook linked folder so I'm wondering if there is any chance to write some VB instructions in order to get this working. I found something similar on the web but not exactly what I need. I tried something like Outlook.Application function but I'm quite lost. Any help GREATLY appreciated.
Thanks in advance and sorry for my english
Apr 29 '10 #1

✓ answered by Jim Doherty

@fsommi
Hello again fsommi

You can attach your Outlook inbox to Access as you have discovered. (You can attach any folder from Outlook in this manner actually) but the presentation as you have seen is in a fixed column layout and does not contain the attachments nor indeed any reference to them other than a yes/No boolen flag column.

There is no magical easy command in Access that enables you to just open Outlook at a particular email message and show you in the outlook window.

You mentioned there exists no unique key for an email message?, actually there is, but it is not exposed within Access... it is in Outlook. The field is called EntryID.

EntryID is the item of data assigned to the email message you 'could' use this a point of reference to work with in Access.....a unique primary key if you will.

Attachment filenames are also in Outlook and of course we know we can attach one or more files to a conventional email message when it is sent when we use Outlook.

So how do we deal with this data in Access? we do that by automation by importing INTO Access so that we can manipulate it in some form or another using recordsets. In doing so we grab whatever we can from Outlook to enable us to see the mail message in Access and manipulate potentially many filename attachments so that we can view them or open them in a native program (ie .DOC, .PDF, .JPG) by simply clicking on a button or double clicking a textbox within Access.

You will appreciate that if we are working IN Access we can never see anything unless we import it, in one form or another, whether that is table stored or held in memory temporarily and displayed on a form.

I have 'knocked up' a database today that I have attached for you. (written in Access 2000) This demonstrates the interaction between Access and your inbox. Take a look, rip it apart and see what you can do with it. The main form to open is a form called frmEmail.

This form calls code from a code module and relies on a value in a lookup table to set a folder path for extracting your inbox attachments into. If the folder does not exist then it will create it for you.

The code loops through your inbox importing your email messages into a table called tblEmail. It examines attachments and if they exist pumps each filename into a table called tblFileAttachments. Each row in this table is one file and is referenced by the EntryID I spoke of earlier. The code goes on to create the file in the extraction folder.

We have then two tables one for mail messages and one for attachments the classic one to many relationship essentially. The form displays buttons enabling you to go straight to the file in explorer without having to find it per se. Alternatively you can view the attachment in a native program FROM Access (ie a program associated with the file extension on your PC)

This may indeed not be what serves your needs best, but at least is a start for any research you might have

Happy Coding :)

Share this Question
Share on Google+
7 Replies


Jim Doherty
Expert 100+
P: 897
@fsommi
Your post is a little confusing! you have linked the folder as an attachment into Access yet you cannot read the messages? the table contains the body column and the relevant CC and BCC associated with email messages and the data. How come you cannot simply manipulate what you now see as an attached table in Access ie: create a form based on the attached table or query the table for whatever it is you need to do?


Welcome to Bytes :)
Apr 30 '10 #2

P: 4
Hi Jim,
Thanks so much for your reply and sorry for the confusion. I try to explain more clearly. I attached an Outlook mailbox (Inbox) as an attached table. The attached table contains all relevant massage fields (sender, subject, CC, body message, etc.) I also created a form based on the attached table and I can view and manipulate all. Anyway most emails contain an attachment which is not available in the attached table (only a yes/no flag is displayed to check whether a file is attached). If I want to open the attached file I first need to open the original email message (in its own Outlook window). Is it possible to do this starting from the Access form based on the attached table?
I would like to view email messages attachments directly from Access, whitout beeing forced to switch to Outlook main window instead.
Thanks in advance for your help
Apr 30 '10 #3

Jim Doherty
Expert 100+
P: 897
@fsommi
Ok I understand you better now I will have a look at this a little later today and come back.
Apr 30 '10 #4

Jim Doherty
Expert 100+
P: 897
@fsommi
Hello again fsommi

You can attach your Outlook inbox to Access as you have discovered. (You can attach any folder from Outlook in this manner actually) but the presentation as you have seen is in a fixed column layout and does not contain the attachments nor indeed any reference to them other than a yes/No boolen flag column.

There is no magical easy command in Access that enables you to just open Outlook at a particular email message and show you in the outlook window.

You mentioned there exists no unique key for an email message?, actually there is, but it is not exposed within Access... it is in Outlook. The field is called EntryID.

EntryID is the item of data assigned to the email message you 'could' use this a point of reference to work with in Access.....a unique primary key if you will.

Attachment filenames are also in Outlook and of course we know we can attach one or more files to a conventional email message when it is sent when we use Outlook.

So how do we deal with this data in Access? we do that by automation by importing INTO Access so that we can manipulate it in some form or another using recordsets. In doing so we grab whatever we can from Outlook to enable us to see the mail message in Access and manipulate potentially many filename attachments so that we can view them or open them in a native program (ie .DOC, .PDF, .JPG) by simply clicking on a button or double clicking a textbox within Access.

You will appreciate that if we are working IN Access we can never see anything unless we import it, in one form or another, whether that is table stored or held in memory temporarily and displayed on a form.

I have 'knocked up' a database today that I have attached for you. (written in Access 2000) This demonstrates the interaction between Access and your inbox. Take a look, rip it apart and see what you can do with it. The main form to open is a form called frmEmail.

This form calls code from a code module and relies on a value in a lookup table to set a folder path for extracting your inbox attachments into. If the folder does not exist then it will create it for you.

The code loops through your inbox importing your email messages into a table called tblEmail. It examines attachments and if they exist pumps each filename into a table called tblFileAttachments. Each row in this table is one file and is referenced by the EntryID I spoke of earlier. The code goes on to create the file in the extraction folder.

We have then two tables one for mail messages and one for attachments the classic one to many relationship essentially. The form displays buttons enabling you to go straight to the file in explorer without having to find it per se. Alternatively you can view the attachment in a native program FROM Access (ie a program associated with the file extension on your PC)

This may indeed not be what serves your needs best, but at least is a start for any research you might have

Happy Coding :)
Attached Files
File Type: zip emails.zip (35.8 KB, 298 views)
May 1 '10 #5

P: 4
Hello Jim,
Thank you very much for your help. It seems to be a great solution indeed and a really effective point of start. I'll test your code and come back later.
May 3 '10 #6

P: 4
Hi Jim,
I tested your code and it works fine! I will adjust it to make it suitable for my porpouse even if I would prefer not to fully import mailbox messages and attachments into Access tables (anyway I agree this is the best way to directly manage mailbox content from an Access database).
I need to import not just the default inbox but specific Outlook mailbox, so now I'm coding in order to make this working. I will post results as soon as ready.

Thanks so much again for your help
May 5 '10 #7

Jim Doherty
Expert 100+
P: 897
@fsommi
You,re welcome, glad it helps you a little :)
May 5 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.