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

Access - Outlook Run Time Error

P: 1
Hi all,
I am trying to move emails from Outlook into an Access table, the code below worked for me before, but now I am having a problem as this error message comes up: Run-time error 438 'Object doesn't support this property or method', for some emails is ok, but otherones, it just cant find the data of certain fields such as Received Time, From etc
Please if someone could help me with some advice.. Thankss

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  
  3.     Dim Olapp As Outlook.Application
  4.     Dim Olmapi As Outlook.NameSpace
  5.     Dim Olfolder As Outlook.MAPIFolder
  6.     Dim OlMail As Object
  7.     Dim OlMessage As Outlook.MailItem
  8.     Dim OlItems As Outlook.Items
  9.     Dim OlRecips As Outlook.Recipients
  10.     Dim OlRecip As Outlook.Recipient
  11.     Dim db As DAO.Database, rst As DAO.Recordset
  12.     Dim flgSave As Boolean
  13.     Dim DQ As String
  14.  
  15.  
  16.     'Dim SubFolder As MAPIFolder
  17.     Set db = CurrentDb
  18.     Set rst = db.OpenRecordset("tbl_Mail", dbOpenDynaset) 'Open table tblMail
  19.  
  20.     'Create a connection to outlook
  21.     Set Olapp = CreateObject("Outlook.Application")
  22.     Set Olmapi = Olapp.GetNamespace("MAPI")
  23.  
  24.     'Open the PSC-EMEA inbox
  25.  
  26.     Set Olfolder = Olmapi.GetDefaultFolder(olFolderInbox).Folders.Item("Mail Read")
  27.     Set OlItems = Olfolder.Items
  28.  
  29.     For Each OlMail In OlItems
  30.  
  31.              If OlMail.UnRead = True Then
  32.  
  33.                         rst.AddNew
  34.                         rst!Date = OlMail.ReceivedTime
  35.                         rst!Time = OlMail.ReceivedTime
  36.                         rst!From = OlMail.SenderName
  37.                         rst!Subject = OlMail.Subject
  38.                         rst!Body = OlMail.Body
  39.                         rst!CreationTime = OlMail.CreationTime
  40.                         rst!LastModificationTime = OlMail.LastModificationTime
  41.                         rst!Last_Checked = Now
  42.                         rst.Update
  43.  
  44.                         OlMail.Delete
  45.  
  46.                 End If   
  47.    Next OlMail
  48.  
  49. MsgBox "New mails have been updated. Please check the tbl_Mail details", vbOKOnly
  50.  
  51.    'Release memory
  52.    Set Olapp = Nothing
  53.    Set Olmapi = Nothing
  54.    Set Olfolder = Nothing
  55.    Set OlItems = Nothing
  56.    Set OlMail = Nothing
  57.    Set OlMessage = Nothing
  58.    Set rst = Nothing
  59.    Set db = Nothing
  60.  
  61.    End Sub
Jun 6 '07 #1
Share this Question
Share on Google+
2 Replies


debasisdas
Expert 5K+
P: 8,127
Since u had put a question in the cafe .I am moving it to proper forum.

Please take care in the future regarding this
Jun 6 '07 #2

Expert 100+
P: 218
Hi

One or two things to try first:-
  1. Set breakpoints in your code and use the debugger to determine where the errors are occurring;
  2. Runtime error 438 doesn't have anything to do with data, rather with invalid properties assigned to an object.
If you follow tip 1, you will soon find which objects are giving you the problem. At that stage, you can come back to the forum with some additional info.

HTH
Steve
Jun 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.