469,642 Members | 1,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

Import outlook custom form fields data into access


I have creatd a custom Outlook form with a few custom form fields.
When completed the form is sent to me and goes into my Inbox. This
works fine. Now Iam trying to write some code in Access to import
l;oop though my inbox and pick up all the usesr defined field data
from any messages froma specific subject. I have have mixed and
matched some code I found on the net however it doesn't seem to work
properly. problems I face are:

1. I have published this form in my firms org library however when the
code finds this msg (with the subject stated in the code) it still
prompts me to enable/disable macros. I can open this up directly from
outlook and not get the msg. Am not sure why this happens?

2. The code does work up to the extent that it will only pick up the
specific msg with the subject stated however it does not import the
users defined field data. I have made sure the field name stated does
indeed match etc. However still now joy. I can seem to figure out
why this is?

3. I now also however want to change it so that the code looks to
search a personal folder instead of my inbox. I will get hundreds of
responses which I want to set up a rule to filter to a persoanl folder
from there I want to run the code at the end of the week to pick up
all the data...without the macro warning!

The code i am using now is as below:

Sub ImportDataFromOutlook()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("results")
Dim Ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.MailItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim inumreplies As Integer
Dim countitems As Integer
DoCmd.SetWarnings False
Set olns = Ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderInbox)
Set objItems = cf.Items
inumreplies = objItems.Count
countitems = 0
If inumreplies <> 0 Then
For i = 1 To inumreplies
If TypeName(objItems(i)) = "mailitem" Or objItems(i) = "MI
Group - Customer Satisfaction Survey" Then
countitems = countitems + 1
Set c = objItems(i)
rst!part1a = c.UserProperties("MIQ1")
rst!Date = Now
End If
Next i
DoCmd.SetWarnings True
MsgBox "Finished. " & countitems & " Mails imported from " & i -
1 & " mails in inbox"
MsgBox "No Mails to import."
End If
End Sub
Any help and advise on this would be greatly appriciated!


Nov 13 '05 #1
1 7888
Hi Kunal

1. If your code were written in Outlook, you could use the program
Selfcert.exe (which is on the Office 2000 and 2002 CDs) to certify
your code. This would prevent the Enable/Disable prompt from

Even with the "Enable/Disable" prompt disabled, the latest Outlook
security patches may still intervene with a different prompt, saying
"A program is trying to do something with Outlook. Do you want to
allow this?" And you will have to wait 10 seconds before you can
reply "Yes, allow this for, say, 10 minutes."

There is a way round this second security issue. You will have to get
hold of the Redemption Library and rewrite your code appropriately.
You'd create a reference to the library first (in the vba editor on
the Tools References menu). The Redemption Library is available from
http://www.dimastr.com/redemption/ For more information on how to
use the library, you might want to get hold of Sue Mosher's book
"Microsoft Outlook Programming - Jumpstart for Administrators,
Developers and Power Users" and visit her web site www.slipstick.com.

2. You're using "UserProperties" to extract the data from the
Outlook form attached to the mail. Sorry, I can't help with this.

3. To point to a different folder - Each Outlook folder has a
folders collection. So, if you had a subfolder in your InBox called
"My Survey Folder", you could point to it by extending your code:

Set cf = olns.GetDefaultFolder(olFolderInbox)
Set objMySurveyFolder = cf.Folders.Item("My Survey Folder")

Also the Namespace.PickFolder method allows you to select a folder at

(Again, good examples of all this in Sue's book.)

Good luck.

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jon Ole Hedne | last post: by
1 post views Thread by David Berry | last post: by
6 posts views Thread by Kevin | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.