OrbitMascot
Programmer
I am working with a database in Access 97. The database currently extracts emails from Outlook and tracks the emails in Access. Everything in the database works fine. But the database randomly selects emails from Outlook. Is there a way for Access to extract the oldest email first? Any information would be greatly appreciated.
Here is the first part of the code:
Private Sub Command0_Click()
Forms!Main.TimerInterval = 0
Dim dbs As Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim textline As String
Dim myselection As String
Dim text As String
Dim Line As String
Dim molApp As Outlook.Application
Dim molNameSpace As Outlook.NameSpace
Dim molMAPI As Outlook.MAPIFolder
Dim molItems As Outlook.Items
Dim molMail As Outlook.MailItem
Dim MyText As String
Dim X As Variant
Dim MyStart As Variant
Dim i As Variant 'Integer
Dim iCount As Variant 'Integer
Set rst = CurrentDb.OpenRecordset("tblEmail")
Set molApp = CreateObject("Outlook.Application")
Set molNameSpace = molApp.GetNamespace("MAPI")
Set molMAPI = molNameSpace.GetDefaultFolder(olFolderInbox)
Set molItems = molMAPI.Items
Dim objOLApp As Object, objFolder As Object, objItem As Object
Dim OlMapi As Object, mydestfolder As Object, SubFolder As Object
Set objOLApp = CreateObject("Outlook.Application")
Set OlMapi = objOLApp.GetNamespace("MAPI")
Set mydestfolder = molNameSpace.GetDefaultFolder(olFolderInbox).Folders.Item("ProcessedEmails")
On Error GoTo Stop_Crash
iCount = molItems.Count
For i = 1 To iCount
If iCount = 0 Or IsNull(iCount) Then
rst.Close
Forms!Main.TimerInterval = 20000
DoCmd.Close acForm, "Automated", acSaveYes
Else
'For Each iCount In molItems
On Error Resume Next
If TypeName(molItems(i)) = "MailItem" Then
On Error GoTo Stop_Crash
mycount = i
mylastvendor = ""
Me.Repaint
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from tmpTextLine"
DoCmd.SetWarnings True
Set molMail = molItems(i)
If molMail.SenderName Like "Store" & "*" And molMail.Body Like "*" & "Qty" & "*" And molMail.Body Like "*" & "Description" & "*" And molMail.Body Like "*" & "Date" & "*" And molMail.Body Like "*" & "Shop" & "*" Then
....
Here is the first part of the code:
Private Sub Command0_Click()
Forms!Main.TimerInterval = 0
Dim dbs As Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Dim textline As String
Dim myselection As String
Dim text As String
Dim Line As String
Dim molApp As Outlook.Application
Dim molNameSpace As Outlook.NameSpace
Dim molMAPI As Outlook.MAPIFolder
Dim molItems As Outlook.Items
Dim molMail As Outlook.MailItem
Dim MyText As String
Dim X As Variant
Dim MyStart As Variant
Dim i As Variant 'Integer
Dim iCount As Variant 'Integer
Set rst = CurrentDb.OpenRecordset("tblEmail")
Set molApp = CreateObject("Outlook.Application")
Set molNameSpace = molApp.GetNamespace("MAPI")
Set molMAPI = molNameSpace.GetDefaultFolder(olFolderInbox)
Set molItems = molMAPI.Items
Dim objOLApp As Object, objFolder As Object, objItem As Object
Dim OlMapi As Object, mydestfolder As Object, SubFolder As Object
Set objOLApp = CreateObject("Outlook.Application")
Set OlMapi = objOLApp.GetNamespace("MAPI")
Set mydestfolder = molNameSpace.GetDefaultFolder(olFolderInbox).Folders.Item("ProcessedEmails")
On Error GoTo Stop_Crash
iCount = molItems.Count
For i = 1 To iCount
If iCount = 0 Or IsNull(iCount) Then
rst.Close
Forms!Main.TimerInterval = 20000
DoCmd.Close acForm, "Automated", acSaveYes
Else
'For Each iCount In molItems
On Error Resume Next
If TypeName(molItems(i)) = "MailItem" Then
On Error GoTo Stop_Crash
mycount = i
mylastvendor = ""
Me.Repaint
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from tmpTextLine"
DoCmd.SetWarnings True
Set molMail = molItems(i)
If molMail.SenderName Like "Store" & "*" And molMail.Body Like "*" & "Qty" & "*" And molMail.Body Like "*" & "Description" & "*" And molMail.Body Like "*" & "Date" & "*" And molMail.Body Like "*" & "Shop" & "*" Then
....