Somos Expertos Access. Contacto atravez de Skype Skype logo expertos_7

Importing Outlook emails into Access

I love Microsoft Office and how we can integrate all of the apps into a cohesive solution. This article will show you how to read emails into Access and save any attachments.

Why Store Emails? Because the’re difficult to share
I built a custom order tracking tool for my client used by 30 employees at the company. Orders can range from $100,000 to several million dollars and can take years to build and close. During the order’s life, emails will travel back and forth between customers and employees at the company, providing a wealth of knowledge relative to the order. It was difficult to share emails with other employees on a order using Exchange, that’s when the firm asked me to come up with a way to import them into Access/SQL Server, allowing all employees to see email info in Access regardless of who received them at the company. I created a new tab on the order screen called Order Notes and added a new button called Import Emails. Users can add notes or emails to the system using the same form. If they land on a email the “View Attachments” button becomes available if there were attachments stored with the email.

The Strategy
My client wanted to save the body of the email into a SQL Server table and any attachments to a network directory set aside for document storage for the database, then display the emails on a continuous form inside Access. This strategy allows the client to search for text in the email and even perform queries against the data.

This is not the only way to store archived emails, you could for example save individual emails by selecting File Save As in Outlook and placing them on a networked drive then referencing them as a link in Access. Users can then click to open the email using Outlook. Using this approach will preserve the formatting of the message and the attachments.

Select the method that bests suits you, display email in Access and do queries or display it in Outlook and preserve formatting.

Outlook Folder Maze

One thing you will quickly realize when you try to import emails into Access is that most people’s inbox are quite large, hence, it can take a very long time to scan all emails. Instead create two folders under the inbox called Import and Imported, than have the user move any emails they wish to import into the former. The code will then move the emails to Imported once the process has been completed.

The second thing about mail folders in Outlook is they don’t follow a specific organization from user to user, since they may place folders in different places thus you’re asking for trouble if you hard code folder locations. Better to cycle through all folders until you find the ones you’re looking for and that’s what the code does.

I took the extra step of showing which emails a user can import into the system by using a temp table and a form, allowing them to cherry pick which ones they want imported into which order in Access. It reduces the need to shuffle back and forth between the two programs when you need to import into different records.

Import and Move or Import all then Move? I’m moved you asked…
I decided to move the email while I had a pointer on the message instead of importing all emails and then moving them. When you move the email it reset’s the collection, hence the code starts again to search for emails after each move.

EntryID is your ticket to ride
Each message in Outlook gets a unique number called EntryID, I use it in the code to identify which emails to import after the user has selected them on the import form. A caveat should be noted though – EntityID will be changed whenever you move a message, so don’t rely on it to reference messages as you would a primary key of a table but more like a pointer.

Beware what you wish for
Have you seen emails lately? They contain graphics, html code and who knows what. In order to save the email body as text in SQL Server, I needed to take care of apostrophes and other vermin that can interfere with my import, all of which you will see in the code.

You can find the code here.

Need to read emails into Access but find it daunting? Then hire us to do it for you! Click here to contact us.

Acerca de

Juan Soto es un desarrollador senior de Access en IT Impact Inc. y un MVP de Microsoft Access y se especializa en Access con bases de datos de SQL Server. Su pasión por el acceso lo ha llevado ayudar a una amplia gama de empresas a establecer un entorno seguro, estable y eficiente con SQL Server. Él es un orador frecuente en los grupos de usuarios de Access en todo el país y recientemente habló en el Orange County SQL Saturday # 73. Si desea que Juan hable en su próxima reunión de grupo, puede ponerse en contacto con él aquí.

Publicado en Access Help, Outlook VBA, VBA

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

*

 

Quienes Somos

ExpertosMicrosoftAccess.com es un servicio de la empresa IT Impact, Inc., una compañía de programación y servicios para empresas en Latino América. Ofrecemos servicios en .Net, SQL Server y Microsoft Access. Muchos de nuestros desarrolladores han obtenido el galardón de Access MVP, un título proveído por Microsoft a aquellos que han hecho aportes a la comunidad y que han demostrado tener conocimientos superiores del producto.

Nuestro Equipo

  • Le ayudamos a "Descubrir el poder de sus datos™" con reportes y sistemas de Access excepcionales .
  • Creamos soluciones de bases de datos personalizadas utilizando Microsoft Access y / o SQL Server.
  • Nuestros consultores ganaron sus estrellas en las empresas de servicios y/o manufactura antes de convertirse en programadores.

Blogs anteriores