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

Import outlook custom form fields data into access

P: n/a
KS
Hi,

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.AddNew
rst!part1a = c.UserProperties("MIQ1")
rst!Date = Now
rst.Update
End If
Next i
rst.Close
DoCmd.SetWarnings True
MsgBox "Finished. " & countitems & " Mails imported from " & i -
1 & " mails in inbox"
Else
MsgBox "No Mails to import."
End If
End Sub
Any help and advise on this would be greatly appriciated!

Regards

Kunal
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
appearing.

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
runtime.

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

Good luck.
Geoff


Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.