Read Email - Performance (1 Viewer)

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
Hy,

We are working on a system to have the current vehicle status in our Access DB.

The Idea is that the Drivers send us a Email (over the Navigation system on board) to a specific Email adress. Our DB reads the Inbox of that Emailadress and changes the Status of the Vehicle.

The Emails, for the Status change, have to look like this

$$StatusIDNr,XX##

example:

$$U65,EO##

The StatusIDNr is generated in our DB and send to the Vehicle Navigation System. XX are the two Status codes that can be FE,BE,EO and so one.

All that is alredy done with this two modules:

module (Check_Mail) - it checks if there are mails with Status codes in it and marks the emails without status code as read emails

Code:
Public Function Check_Mail()
On Error Resume Next

Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim countE As Integer

countE = 0

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetFolderFromID(DLookup("Status_OO", "tbl_Glob_Var", "[ID]=1"))

Set InboxItems = Inbox.Items

For Each Mailobject In InboxItems
    If Mailobject.UnRead Then
    
        If Mailobject.Body Like "*$$*" Then
        countE = countE + 1
        Else
        Mailobject.UnRead = False
        End If

    End If
    Next

If countE <> 0 Then Call mdl_Read_Mail.Read_Mail

End Function

If there are Unred Emails with status codes in it the second module will run

Code:
Public Function Read_Mail()
On Error Resume Next
Dim Styletronic_Nachricht_von_Fahrzeug, Styletronic_Fahrer, Styletronic_Uhrzeit, Styletronic_Position, Styletronic_Nachricht, Styletronic_Status As String

Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetFolderFromID(DLookup("Status_OO", "tbl_Glob_Var", "[ID]=1"))

Set InboxItems = Inbox.Items

For Each Mailobject In InboxItems
 If Mailobject.UnRead Then

Nachricht = Mailobject.Body
Erstellt = Mailobject.CreationTime

'If InStrRev(Nachricht, "Uhrzeit:") > 0 Then
'Styletronic_Uhrzeit = Nz(Replace(Mid(Nachricht, InStrRev(Nachricht, "Uhrzeit:") + 8, InStrRev(Nachricht, "Position:") - InStrRev(Nachricht, "Uhrzeit:") - 8), Chr(13), ""), "")
'Else
Styletronic_Uhrzeit = Erstellt
'End If

If InStrRev(Nachricht, "Position:") > 0 Then
Styletronic_Position = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "Position:") + 9, InStrRev(Nachricht, "Nachricht:") - InStrRev(Nachricht, "Position:") - 9)), "nicht angegeben"), Chr(13), "")
Else
Styletronic_Position = "Unknown Location"
End If

Styletronic_Status = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "$$") + 2, InStrRev(Nachricht, "##") - InStrRev(Nachricht, "$$") - 2)), "X"), Chr(13), "")
styletronic_ID = Trim(Mid(Left(Styletronic_Status, InStr(Styletronic_Status, ",") - 1), 2))
Styletronic_Liste = Left(Styletronic_Status, 1)
Styletronic_FULL_EMPTY = Nz(Left(Right(Styletronic_Status, 2), 1), "X")
Styletronic_IN_OUT_BEGIN_END = Nz(Right(Right(Styletronic_Status, 2), 1), "X")
                        
If DCount("STATUS_ID", "qry_Status_" & Styletronic_Liste & " , [STATUS_ID] like '*" & styletronic_ID & "*'") <> 0 Then
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE qry_Status_" & Styletronic_Liste & "  SET [IN_OUT_BEGIN_END]='" & Styletronic_IN_OUT_BEGIN_END & "',  [FULL_EMPTY]='" & Styletronic_FULL_EMPTY & "' , [DATE_TIME]='" & Styletronic_Uhrzeit & "' , [PLACE_OF_EVENT]='" & Styletronic_Position & "'  WHERE [STATUS_ID]='" & styletronic_ID & "' ;"
DoCmd.SetWarnings True
End If



Styletronic_Position = ""
Styletronic_Nachricht = ""
Styletronic_Status = ""
Styletronic_ID = ""
Styletronic_Liste = ""
Styaletronic_IN_OUT_BEGIN_END = ""
Styletronic_FULL_EMPTY = ""

        Mailobject.UnRead = False
    End If
    Next

'Call mdl_Status_Export.Status_Export
End Function

All that works fine and like it should.

BUT

The Access Application need about 1 sec for 10 Emails to read. When that hapens it blocks the users for that 1 sec and if there are more Emails it blocks the users for more time :(

The Check_Mail module is runed by a hiden Form every 5 sec.

I know that the String Functions are slowing the Procedure down. Can they me made bether/faster? Is there maby a bether way to do something like this?

Every suggestin is eprisiated :)

P.S.

When the Email is send from the navigation system it contains also the txt:

Position: "the current position of the vehicle"

Ofcourse we want to use that Data in our DB :)
 

spikepl

Eledittingent Beliped
Local time
Today, 02:07
Joined
Nov 3, 2010
Messages
6,142
  1. When you submit code for advice, have the decency to indent it. Yes we can read your code, but why do you make it so much more difficult? If you cannot figure it out on your own then use a tool like this one: http://www.accessui.com/FreeAccessTools/SmartIndenter/tabid/74/Default.aspx
  2. Using Resume Next as substitute for proper error handling is a really poor choice
  3. Use of Option Explicit is highly recommended - use it
  4. Declaring a whole row of variables like Dim a,b,c,d As String gives 3 Variants and 1 string
  5. Your code is very poorly structured - you create objects and run through the the Inbox, but then you repat this entire loop, if you have found mails of interest. DO all this in one go, not in two rounds. Or at least pass references to the objects oif interest in the arguments of the function, instead of creating them again.
  6. Why do you use Like ** as search criterion in your Dcount? That will be much slower than using MyField=SomeValue, which can take advantage of indexing. Verify that the variable you search on is indexed indeed
  7. You repeat all this each X seconds. Do you know that you can create a macro in Outlook, which gets triggered by certain content in certain mails, and then that macro could then run your code? In htis way only mails of interest would get processed. I do not know how often you get updates though
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
Thank you :D

That kind of sugestionas are those I was Serching for :D

I´m working with Acces for 6 Months so I realy have lots of things to learn.
At the begining I was happy if my codes just did what i want to. Now with a growing DB the performance becomes more importand.

Of course I regret lots of mistakes made with the first steps :(

Thank you again. I´ll try to apply your sugestions as son as I can.
 

spikepl

Eledittingent Beliped
Local time
Today, 02:07
Joined
Nov 3, 2010
Messages
6,142
If you got this far in 6 months then well done!

Another comment - why do you use dcount at all? To check if the record to update exists already? If it doesn't where and when is that record made then? Also, you could skip that check altogether and just run the Update query. If the update query does not find the thing to update, then there is no problem. :D
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
OK

Could not wait to apply all that changes :D and it was worth of it :D

I don´t know how to thank you. You realy helped my a lot!

Now the code looks like this (in just one module)

Code:
Option Explicit

Public Function Status()
'On Error Resume Next

Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim countE As Integer
Dim rs As Recordset

Dim Styletronic_Uhrzeit As String
Dim Styletronic_Position As String
Dim Styletronic_Nachricht As String
Dim Styletronic_Status As String
Dim Styletronic_ID As String
Dim Styletronic_Liste As String
Dim Nachricht As String
Dim Stylettronic_Uhrzeit As String
Dim Styletronic_FULL_EMPTY As String
Dim Styletronic_IN_OUT_BEGIN_END As String
Dim Outlook_Inbox_FolderID As String

Set rs = CurrentDb.OpenRecordset("SELECT Status_OO FROM tbl_Glob_Var WHERE [ID]= 1 ;")
Outlook_Inbox_FolderID = Nz(rs!Status_OO, "")

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetFolderFromID(Outlook_Inbox_FolderID)
Set InboxItems = Inbox.Items

For Each Mailobject In InboxItems

    If Mailobject.UnRead Then
    
        If Mailobject.Body = "*$$*" Then
        
            Nachricht = Mailobject.Body
            Styletronic_Uhrzeit = Mailobject.CreationTime
            
            If InStrRev(Nachricht, "Position:") > 0 Then
            Styletronic_Position = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "Position:") + 9, InStrRev(Nachricht, "Nachricht:") - InStrRev(Nachricht, "Position:") - 9)), "nicht angegeben"), Chr(13), "")
            Else
            Styletronic_Position = "Unknown Location"
            End If

            Styletronic_Status = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "$$") + 2, InStrRev(Nachricht, "##") - InStrRev(Nachricht, "$$") - 2)), "X"), Chr(13), "")
            Styletronic_ID = Trim(Mid(Left(Styletronic_Status, InStr(Styletronic_Status, ",") - 1), 2))
            Styletronic_Liste = Left(Styletronic_Status, 1)
            Styletronic_FULL_EMPTY = Nz(Left(Right(Styletronic_Status, 2), 1), "X")
            Styletronic_IN_OUT_BEGIN_END = Nz(Right(Right(Styletronic_Status, 2), 1), "X")
                            
            DoCmd.SetWarnings False
            DoCmd.RunSQL "UPDATE qry_Status_" & Styletronic_Liste & "  SET [IN_OUT_BEGIN_END]='" & Styletronic_IN_OUT_BEGIN_END & "',  [FULL_EMPTY]='" & Styletronic_FULL_EMPTY & "' , [DATE_TIME]='" & Styletronic_Uhrzeit & "' , [PLACE_OF_EVENT]='" & Styletronic_Position & "'  WHERE [STATUS_ID]='" & Styletronic_ID & "' ;"
            DoCmd.SetWarnings True
            
            Styletronic_Uhrzeit = ""
            Styletronic_Position = ""
            Styletronic_Nachricht = ""
            Styletronic_Status = ""
            Styletronic_ID = ""
            Styletronic_Liste = ""
            Styletronic_IN_OUT_BEGIN_END = ""
            Styletronic_FULL_EMPTY = ""

            Mailobject.UnRead = False
 
        Else
        
            Mailobject.UnRead = False
        End If
    End If
    
Next

'This Fuction I will need later
'Call mdl_Status_Export.Status_Export
End Function

Now it runs 10 times faster :D The old code could read 10 Emails in one second. This one reads 100 in one second :rolleyes:

Sme more cuestions:

Somewhere I readed that SQl is faster than Dlookup so I changed the Dlookup for the FolderID with a SQl statement.

I realy don´t like macros :( but I´m REALY interestet how that will work with the macro function you sugested...

I use a very good errorhandler in my other codes. I put the resume next handlinge because the emails that come inside are and wont be so homgeneus that this code could handle them all. Because the Access DB is runing all the time and every day a error handling like my standard one is to big.

The sandard one (runed from every code in the DB over this module):

Code:
Function ErrorLog(strErrDesc As String, lngErrNum As Long, strForm As String, strSub) As Boolean

On Error GoTo Err_ErrorLog
Dim strMsg, strBenutzer As String

ErrorLog = True


'Die Fehlermeldung fur den Benutzer

'Text der Fehlermeldung
strMsg = strMsg & "Beschreibung: " & strErrDesc & vbNewLine & vbNewLine
strMsg = strMsg & "Nummer: " & lngErrNum & vbNewLine & vbNewLine
strMsg = strMsg & "Der Administrator wurde automatisch benachrichtigt!"

'Ausführen der Fehlermeldung
MsgBox strMsg, vbCritical, "Fehlermeldung"


strBenutzer = Nz(DLookup("Benutzer", "tbl_Glob_Var", "ID=1"), "Unbekannt")

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tbl_Error_Handling " & _
             " ([Nummer],[Beschreibung],[Zeit],[Formular],[Funktion],[Benutzer]) " & _
             " VALUES ( """ & lngErrNum & """, """ & strErrDesc & """,""" & Now() & """,""" & strForm & """,""" & strSub & """, """ & strBenutzer & """) ; "
DoCmd.SetWarnings True
                   
           
Dim An, Betreff, Nachricht As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
An = "tarik.huber@ics-logistik.com"
Betreff = "Fehlermeldung"
Nachricht = "Fehlernummer: " & lngErrNum & vbNewLine & "Fehlerbeschreibung: " & strErrDesc & vbNewLine & "Formular: " & strForm & vbNewLine & "Funktion: " & strSub & vbNewLine & "Benutzer: " & strBenutzer
With objEmail
    .To = An
    .Subject = Betreff
    .Body = Nachricht
    .Send
End With
Set objEmail = Nothing
           

'DoCmd.SendObject acSendNoObject, , , "tarik.huber@ics-logistik.com", , , "Fehlermeldung", "Fehlernummer: " & lngErrNum & vbNewLine & "Fehlerbeschreibung: " & strErrDesc & vbNewLine & "Formular: " & strForm & vbNewLine & "Funktion: " & strSub & vbNewLine & "Benutzer: " & strBenutzer, False


Exit_ErrorLog:
Exit Function

Err_ErrorLog:
ErrorLog = False
MsgBox Err.Description, vbExcalmation, "Fehler gefunden!"
Resume Exit_ErrorLog
End Function

I don´t want to interupt the useres only because a corrupt email came into the status inbox. A big errorhandler would also slow the fuction if there are small errors.

Because the txt in the emails will be different the instrev function often would not find anithing and becomes the value nothing or 0 and in that case the string functions just "crash".

The number of emails.
1 Day hubdrets
1 Month Thousands
1 Year Milions :eek:

Thank you again :) Can it be made more bethar and faster?
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
AAAAAAAAAAA Crap!

I know it was to good to be truth :(

The

Code:
="*$$*"

without the LIKE didn´t recognise the email so that every one was just skiped and of course it then become faster :(

It truly is faster than the old code but just slightly. It is remaining in the 10 Emails per second :(

Now the MACRO THING becomes more interesting ;)

Is there maby a way to do all that in the backgrount of the PC or Access DB with less usage of workspace so that it won´t interrupt the users by blocking Accesss whyle runingt that function ????? :confused:

Some more information:

The Accss DB is runed ina multiuser environment. So:
Could the function runed by one user interrupt the same function runed by a other user????

Could this more users split the message amount so that the function is runed every 1 min by 5 users so that it is actualy runed 1min/5???? Can it be synced so that it doesnt run simultaneusly at the same time???

Sorry for all that cuestions but i´m realy enjoing to do coding like this :D i actualy enjoi doing coding at all :D
 

spikepl

Eledittingent Beliped
Local time
Today, 02:07
Joined
Nov 3, 2010
Messages
6,142
Find another way of determining whether you want to read that mail or not. Loooking for "$$" perhaps? Or sender?

Yoiu could play with the macros in Outlook. They offer many way to identify a mail and doing something with it.

One of the things that an Outlook macro can do is to run som code. This requires some effort, because Outlook is structurally different from Access. Search for Outlook Object Model - there also code examples there

A big errorhandler would also slow the fuction if there are small errors.

No. You define what happens in each instance, so you choose which errors are handled how (or whether they are ignored). RIght now you seemingly use two ways of handling errors: ignore them all, or log them all. No law says that you cannot select which errors you handle how.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:07
Joined
Aug 30, 2003
Messages
36,127
A couple of thoughts in addition to spike's good ones. First, you loop the entire inbox every time, which is slowing you down a little. If appropriate, I'd move the emails to a subfolder after handling, so the code doesn't have to loop through them any more. That probably wouldn't be a major factor, but may help. Secondly, I'd use either a virtual machine or an unused PC to process the emails, so that processing wouldn't (shouldn't?) interfere with a user's activity.
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
Thank you bouth for your suggestions! :)
You have greate Ideas!

I was also thinking about moving that function somwhere else.


Outlook selection:
Outlook can also seperate incoming emails into a specific SubFolder. With the Outlook rules it can be made that Outlook moves a "Status" Email into a "Status" INbox subfolder only if it kontains "$$" in the email body.

Outlook VBA:
VBA can be made in Outlook and how you say probable it could be posible to access the Access DB to update the status variables in the tables. With the mentioned macro that runs the vba it would be the best solution :D

Second Access aplikation:
Could I just run a "hiden" Access application that runs the funktion. Windows automaticaly split the workplace usage so that one Access App don´t disturb a other one. In that case a bether performance would not be needed.

Virtual machine:
A greate Idea. At the first runs on this project it was my main plan to do it over a virtual machine. At that time i was a real noob with VBA and for this "small" funktion i had a "other" access app with some forms, tables ect... :banghead: Realy bad and dirty work :( Of course a virtual machine would solve the problem BUT: a virtual machine runs a whole Windows that runs just for that one app :confused: a performance los at the same start ;) and slo a virtual machine would be needed on all 5 PC of the users :( all in all a very "dirty" solution. Funktional but dirty.

Workplace spliting:
Somewhere i read some txt about Access workplace usage. How i understod it every access app runs with a workplace session. Could it be posible to virtualy make a second workplace session? Would it have the same effect like runing te code ina second access app? I tryed runing the funktion in a seperate access app and let it read 2500 emails, meanwhile i started the access DB that the users use and it was working like it shoult no mather if the second access app was procesing the emails or not :rolleyes:

THank you again :D
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:07
Joined
Aug 30, 2003
Messages
36,127
Random thoughts. Outlook VBA is certainly an option, and I'm sure it can access the data. I've always worked from Access, but only because I'm too lazy to learn the Outlook model. :p

Using a second Access application is a good idea.

You said emails went to a specific address, so the process should only need to be running on one machine, not all users. That's why I suggested a VM.

If I understand what you mean, I don't think workplace splitting gains you anything. The code is still running in the original instance.
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
Thanks :D

I´m also to lazy for the Outlook VBA :( I´m not good enough in Access. Going on to Ooutlook VBA would be madnes ;) but learning little parts for just this function would seam to be worth of the "crazy ride" ;)

A second Access app is also a "dirty" solution :( This function has to work 24/7! Thats why I want to run it on 5 PC by each user. Somone of them always leavs the PC and the Access app ON. No mather of this function.

That is making some problem for the Access app becaus of course Access is not made for 24/7 apps. When they leav PC and app runing and the PC goes standby in the weekend it comes to sync problems. But that is again a whole iferent story ;)

We are working with a exchange server so that it is no problem to give all users access to the email inbox. We will recive every day hundrets of emails in that inbox becaus the drivers send the Status code like a normal message. Only a small part of the email amount will be status messages. Everithing else is stil normal comunikation between drivers and dispechers. One reason more to give all 5 users access to the inbox. They all need to read the messages.

Because the Inbox Folder is not read by a linket table between access and outlook the users can modify the emails inbox from witch to read the emails. A not so hard funktion witch can be very useful in changing environment or problems :D

If this goes good there will also come emails form third part drivers witch will see realy diferent :( This emails right now have a very homogenious strukure.

I come to the conclution:

The BEST way to solve this problem is realy to add this funktion direktly in Outlook VBA and run it with the macro that is trigered by inkoming emails.

I hope that it can be done :rolleyes:
 

Reflex_ht

Registered User.
Local time
Yesterday, 17:07
Joined
Sep 11, 2012
Messages
64
OK

It done :D and it seams to work :D

In the Outlook VBA "ThisOutlookSession" with this code I determinate to run the Status module in Outlook if a new email komes in the Status Folder Inbox.

Code:
Option Explicit

Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
  Dim OlApp As Outlook.Application
  Dim objNS As Outlook.NameSpace
  Set OlApp = Outlook.Application
  Set objNS = OlApp.GetNamespace("MAPI")
  ' default local Inbox
  Set Items = objNS.GetFolderFromID("The Folder ID NUmber").Items
  Call Status.Status
End Sub

Private Sub Items_ItemAdd(ByVal item As Object)

  On Error GoTo ErrorHandler
  Dim Msg As Outlook.MailItem
  If TypeName(item) = "MailItem" Then
    Set Msg = item
    
    Call Status.Status
    
    End If
    
ProgramExit:
  Exit Sub
ErrorHandler:
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Sub

That code I found somewhere on the www.

The Status module in Outlook looks like this:

Code:
Option Explicit

Public Function Status()
'On Error Resume Next
Dim acc As New Access.Application

Dim OlApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim countE As Integer


Dim Styletronic_Uhrzeit As String
Dim Styletronic_Position As String
Dim Styletronic_Nachricht As String
Dim Styletronic_Status As String
Dim Styletronic_ID As String
Dim Styletronic_Liste As String
Dim Nachricht As String
Dim Stylettronic_Uhrzeit As String
Dim Styletronic_FULL_EMPTY As String
Dim Styletronic_IN_OUT_BEGIN_END As String
Dim Outlook_Inbox_FolderID As String

acc.OpenCurrentDatabase ("X:\ICS\DATEN\Outlook.accdb"), False

'Set rs = CurrentDb.OpenRecordset("SELECT Status_OO FROM tbl_Glob_Var WHERE [ID]= 1 ;")
Outlook_Inbox_FolderID = "Folder ID nr"

Set OlApp = CreateObject("Outlook.Application")
Set Inbox = OlApp.GetNamespace("Mapi").GetFolderFromID(Outlook_Inbox_FolderID)
Set InboxItems = Inbox.Items

For Each Mailobject In InboxItems

    If Mailobject.UnRead Then
    
        If Mailobject.Body Like "*$$*" Then
        
            Nachricht = Mailobject.Body
            Styletronic_Uhrzeit = Mailobject.CreationTime
            
            If InStrRev(Nachricht, "Position:") > 0 Then
            Styletronic_Position = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "Position:") + 9, InStrRev(Nachricht, "Nachricht:") - InStrRev(Nachricht, "Position:") - 9)), "nicht angegeben"), Chr(13), "")
            Else
            Styletronic_Position = "Unknown Location"
            End If

            Styletronic_Status = Replace(Nz(Trim(Mid(Nachricht, InStrRev(Nachricht, "$$") + 2, InStrRev(Nachricht, "##") - InStrRev(Nachricht, "$$") - 2)), "X"), Chr(13), "")
            Styletronic_ID = Trim(Mid(Left(Styletronic_Status, InStr(Styletronic_Status, ",") - 1), 2))
            Styletronic_Liste = Left(Styletronic_Status, 1)
            Styletronic_FULL_EMPTY = Nz(Left(Right(Styletronic_Status, 2), 1), "X")
            Styletronic_IN_OUT_BEGIN_END = Nz(Right(Right(Styletronic_Status, 2), 1), "X")
                            
            acc.DoCmd.SetWarnings False
            acc.DoCmd.RunSQL "UPDATE qry_Status_" & Styletronic_Liste & "  SET [IN_OUT_BEGIN_END]='" & Styletronic_IN_OUT_BEGIN_END & "',  [FULL_EMPTY]='" & Styletronic_FULL_EMPTY & "' , [DATE_TIME]='" & Styletronic_Uhrzeit & "' , [PLACE_OF_EVENT]='" & Styletronic_Position & "'  WHERE [STATUS_ID]='" & Styletronic_ID & "' ;"
            acc.DoCmd.SetWarnings True
            
            Styletronic_Uhrzeit = ""
            Styletronic_Position = ""
            Styletronic_Nachricht = ""
            Styletronic_Status = ""
            Styletronic_ID = ""
            Styletronic_Liste = ""
            Styletronic_IN_OUT_BEGIN_END = ""
            Styletronic_FULL_EMPTY = ""

            Mailobject.UnRead = False
 
        Else
        
            Mailobject.UnRead = False
        End If
    End If
    
Next


acc.CloseCurrentDatabase
Set acc = Nothing

'This Fuction I will need later
'Call mdl_Status_Export.Status_Export

End Function

I cant directly access to my Access backend because it is Password protected but with a other Access accdb file containning linked tables to the real backend (only those wotch i need - and they don´t have to be protected) it´s easy.

So:
In Outlook it need the same time to rad the email witch means that the string funktions are the "EVIL" code monsters :eek: slowing all this down. But it is not importand. The code is runing only if there is a email and in that case it can not be notices by the user when that is done i Ooutlook. Even watching it in Outlook how it process one email it can´t be notices. Only by more emails it can be noticed but the user don´t know what is slowing outlook down :D

It´s not done jet.
The error handling must be adjusted but I´m happy that it is working at all :D

Thank you again :D

When i finish the project I´ll post a last reply. Maby there are other problems with this solution.

I noticed that if the Ooutlook runs the function one time after that I can´t open our Access app. Perhaps because it opens the Access backend in hidden mode and access opens all other apps then also in hiden mode. I´ll play a little bit with that.

By errors in Outlook the code that runs the function by a new email crashes and all the status fuction is after that not runing. It also rekognises only emails that are koming in. No mather if they are unread or not. Also if i Open Outlook and there are some emails in the Status FOlder they will not be procesed until a new email comes in. Because of that i just call the status function by every start of Outlook.

:D
 

Users who are viewing this thread

Top Bottom