The four most common chemically active elements in the universe - hydrogen, oxygen, carbon, and nitrogen - are the four most common elements of life on Earth. We are not simply in the universe. The universe is in us.
Dim oApp As Outlook.Application Dim oNS As Outlook.NameSpace Dim oInbox As Outlook.MAPIFolder Dim oCompleted As Outlook.MAPIFolder Dim oMailItem As Outlook.MailItem Dim DB As Database Dim RS As Recordset Dim X As Long, Y As Long
Set oApp = New Outlook.Application Set oNS = oApp.GetNamespace("MAPI") Set oInbox = oNS.GetDefaultFolder(olFolderInbox) 'Set oCompleted = oInbox.Folders("Completed")
Set DB = CurrentDb() Set RS = DB.OpenRecordset("IncomingT", dbOpenDynaset)
For Each oMailItem In oInbox.Items MsgBox oMailItem.Subject Next
I get a type mismatch error where oMilItem is set to nothing.
Is that code directly from the course, or did you modify it? It's been several years since I recorded that class, so I don't remember. Do you have any mail items actually in your inbox?
Michael FlanaganOP
@Reply 5 years ago
The code is from the course. I did get several records into the IncomingT table, but my Outlook inbox (via Gmail) has over 9,000 emails. It seems to limit the number of records I can retrieve and now will not add any new records to the table. I get the type mismatch error where the oMailItem is now null.
I can't recreate the error. I use the same code in my database to pull customer service emails from Outlook into Access. Never a problem. Can you post some screen shots?
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.