473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Access - Outlook Run Time Error

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
2 3623
debasisdas
8,127 Expert 4TB
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
cyberdwarf
218 Expert 100+
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

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

Similar topics

11
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
4
by: MLH | last post by:
I would like to configure OutLook Express so that it does not attempt to resend eMails in the Outbox folder whenever new sends are made From Access. The ISP's server rejects some eMail address...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
2
by: Salad | last post by:
A2003, WinXP I know it is possible to link the Outlook contacts table to Access. Is it possible to call/open the Outlook Contacts window form within Access?
4
by: KnightKnives | last post by:
Is there anyone out there who could help me find the resources I need in order to make this application. I have done a lot of work with 2.0 engine then upgraded to 97; now have 2003. I have...
3
by: scott_baird | last post by:
I have an email macro setup (maybe I should go another way, but that was the quickest at the moment...) and what I would like to do is automate the "to" addressee of the email it generates for...
5
by: horsetransport | last post by:
Hello, Below is what I "Know how to do" but it doesn't accomplish what I want I have table called sndmail fields that matter useremail and mailsent
1
by: ARC | last post by:
Ok, now I'm stuck!! I've been having blue screens a lot whenever I do any serious development in Access 97. I don't get this in 2000, and am currently migrating towards Access 2007. I found an...
2
by: jrworsham | last post by:
Please help! I have an Outlook module opening a connection to Access, writing in some data, and then pulling out some data. But for some reason the code only works the first time and after that you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.