none
display outlook email in acces ... the problems RRS feed

  • Question

  • i'm still in the party-catering business for the moment. When a party is ordered, a lot of email is coming in : people asking for different food , plates, glasses , napkins , ....

    so it would be convenient that if the users  have a party on the screen they could easily see the mails concerning that party

    i have this code for a readinbox module : it reads the mails in the outlook inbox and puts a record  in a file

    so i taught i make a form , with the file of the mailrecords , people can click and immediately have the right email.... that was pretty easy .... too easy , so became suspicious ...

    and indeed, the number you get is ok if there is no mail deleted . perhaps i could solve that with refresh ?

    and i want it in multiuser , so are there some more issues coming up ?

    please advice me  

     Private Sub ReadInbox()
     Dim TempRst As DAO.Recordset
     Dim rst As DAO.Recordset
     Dim OlApp As Outlook.Application
     Dim Inbox As Outlook.MAPIFolder
     Dim InboxItems As Outlook.Items
     Dim Mailobject As Object
     Dim db As DAO.Database
     Dim dealer As Integer
     Dim nr As Integer
     
    DoCmd.SetWarnings False
     
     DoCmd.RunSQL "Delete * from tbl_outlooktemp"
     DoCmd.SetWarnings True
     
     Set db = CurrentDb
     Set OlApp = CreateObject("Outlook.Application")
     Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox)
     Set TempRst = CurrentDb.OpenRecordset("tbl_OutlookTemp")
     '
     Set InboxItems = Inbox.Items
     '
     nr = 1
     For Each Mailobject In InboxItems
       '  If Mailobject.UnRead Then
         With TempRst
            
             .AddNew
             !Subject = Mailobject.Subject
             !From = Mailobject.SenderName
             !To = Mailobject.To
             !Body = Mailobject.Body
             !Datesent = Mailobject.SentOn
             !i = nr
             .Update
             Mailobject.UnRead = False
    nr = nr + 1
     
     
         End With
     ' End If
     Next
    Me.Refresh
     Set OlApp = Nothing
     Set Inbox = Nothing
     Set InboxItems = Nothing
     Set Mailobject = Nothing
     Set TempRst = Nothing
    End Sub

    ' show email

    Private Sub Subject_Click()
    Dim myNameSpace As Outlook.NameSpace
     Dim myFolder As Outlook.Folder
     Dim nr As Integer
     nr = Me.i
     
     
     
     Set myNameSpace = Outlook.Application.GetNamespace("MAPI")
     Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
     On Error GoTo ErrorHandler
     myFolder.Items(nr).Display
     Exit Sub
     
    ErrorHandler:
     
     MsgBox "There are no items to display."
     End Sub

    Thursday, May 12, 2016 2:43 PM

Answers

  • Hi Mr DB guy, i thought the same . but if there are a lot of mails, it al takes a (too) long time , i'm afraid it is not usable. here on my PC it is really perfect, but at the clients place it takes a long time to loop trough al their  mails i noticed.

    and thank you for your answer !


    Okay, makes sense. If I remember correctly, Outlook items have an EntryID, which can identify the specific item you need. Perhaps you can use it rather than the current index you're using. Just a thought...
    • Marked as answer by tekoko10 Thursday, May 12, 2016 8:29 PM
    Thursday, May 12, 2016 6:31 PM

All replies

  • Hi. Not sure if this will help but the only approach I could think of is to loop through all the email in the folder and compare the subject line and date received with your temp table and display the matching email. Just my 2 cents...
    Thursday, May 12, 2016 3:23 PM
  • You are requesting a complete catering software.
    Here are your options:

    1. Learn how to program ...
      OR
    2. Buy software from someone

    Best regards, George


    Thursday, May 12, 2016 3:42 PM
  • what a very friendly answer George
    Thursday, May 12, 2016 3:56 PM
  • You asked, I replied. There is no Push-Button to create a solution of your choice, sorry

    Best regards, George


    Thursday, May 12, 2016 3:59 PM
  • Hi Mr DB guy, i thought the same . but if there are a lot of mails, it al takes a (too) long time , i'm afraid it is not usable. here on my PC it is really perfect, but at the clients place it takes a long time to loop trough al their  mails i noticed.

    and thank you for your answer !

    Thursday, May 12, 2016 4:15 PM
  • Hi Mr DB guy, i thought the same . but if there are a lot of mails, it al takes a (too) long time , i'm afraid it is not usable. here on my PC it is really perfect, but at the clients place it takes a long time to loop trough al their  mails i noticed.

    and thank you for your answer !


    Okay, makes sense. If I remember correctly, Outlook items have an EntryID, which can identify the specific item you need. Perhaps you can use it rather than the current index you're using. Just a thought...
    • Marked as answer by tekoko10 Thursday, May 12, 2016 8:29 PM
    Thursday, May 12, 2016 6:31 PM
  • little bit disenchanted

    why did anyone tip me that i could use this rather simple code to view all the mails from a certain mailadres. it works perfect , even with a lot of mails !

    Sub outlookSearch(searchString As String)
    Dim app As Outlook.Application

        Set app = CreateObject("Outlook.Application")

        app.Explorers.Add app.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)

        app.Explorers(1).Activate

            
    'Search all folders for searchString
    app.ActiveExplorer.Search searchString, olSearchScopeAllFolders
    Set app = Nothing
    End Sub
    Saturday, May 14, 2016 12:51 PM
  • Hi. Probably because you are more familiar with your needs than others. Glad to hear you found a solution on your own. One thing I can think of is the searchString could return unrelated emails. Good luck!
    Saturday, May 14, 2016 3:07 PM
  • thx db guy !

    Saturday, May 14, 2016 3:24 PM
  • You're welcome! Cheers!
    Saturday, May 14, 2016 3:56 PM