Question : Importing Custom Exchange Public Folder Data into Access 2007 table

I am looking to export data from an Exchange 2003 Public folder that holds custom forms and import it into an Acces 2007 database.  So far I have been able to import data from the Exchange Public folder but it will not extract the custom data fields to import them into the Access 2007 table.

A little background might help.  We have created a custom form in Outlook that was based off of a Task item.  It was edited to allow a second page of details that catalogs information about individual client cases.  A task by default did not have enough data fields in it to properly document cases so we created this form to do just that.  We based it on the pre built task form because it already held information about time frames and due dates which we still needed for this Form.  Once we got the form created and working correctly we wanted to export that data so we could post some of this information to a website.

Currently to export anything out of a folder that holds these types of forms you cannot use Outlooks default Export tool to do so.  If you try to do so you will only get the fields that were originally included in a Task object and it will omit the custom fields that we had created.  So I found a piece of software to export this data that is an add-in for Outlook called "CodeTwo Outlook Export".  Using that tool I could choose the custom fields and export that data to a CSV.  This is exactly what I wanted to do.

Now I want to "automate" this "export" as it will allow for a more dynamic website.  I wanted to try and do this with Access so that the data could easily be exported to another application if it needed to be.  So I tried to use the import functionality in Access to do this and used the "Import or link to an Outlook folder" option.  When I do this I get to browse through my public folders and choose the folder that holds all the custom forms but when I go to import this data it only imports the default "Task" fields that this form was based off of and ignores the custom fields we had created.  I have not been able to find any way to fix this.

Does anyone have any idea how to import custom form field data from an Exchange 2003 Public folder into an Access 2007 table?  This seems to be my main issue right now.

Thanks

Answer : Importing Custom Exchange Public Folder Data into Access 2007 table

Something like this will get the job done.  Follow these instructions to use this.

1.  Open Notepad.
2.  Copy and paste the code into Notepad.
3.  Edit the code as needed.  I included comments where things can/should change.
4.  Save the file with a .vbs extension.
5  Double-click the script to run it.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Const olPublicFoldersAllPublicFolders = 18
Dim olkApp, olkSes, olkFld, olkItm, adoCon
Dim a, b, c, d
Set adoCon = CreateObject("ADODB.Connection")
'Change the database file name and path on the next line'
adoCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;"
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
'Change the profile name on the next line as needed'
olkSes.Logon "Outlook"
'Change My Folder to the name of your folder on the next line'
Set olkFld = olkSes.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("My Folder")
For Each olkItm In olkFld.Items
    With olkItm
        'Change the fields on the next 4 lines.  Add additional fields as needed.'
        a = .Subject
        b = .ReceivedTime
        c = .SenderName
        'Change the property name on the next line'
        d = .UserProperties.Item("Your Prop Name").Value
    End With
    'Edit the SQL command as needed'
    olkCon.Execute "INSERT INTO SomeTableName (FieldName1,FieldName2,FieldName3,FieldName4) VALUES('" & a & "','" & b & "','" & c & "','" & d & "')"
Next
adoCon.Close
Set adoCon = Nothing
Set olkFld = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing
msgbox "Finished!"
Random Solutions  
 
programming4us programming4us