Hi Access-Guys,
I use the following code to get all my mails into a table:
I check all the mails in the "import-folder", import the content into the database and after that I move the mails into the "imported-folder".Code:Option Compare DatabaseOption Explicit Private Sub Befehl17_Click() ' ##################### OutlookImport ################################## Dim db As DAO.Database Dim rs As DAO.Recordset Dim outObject, Mapi, Inbox, InboxImported Dim i As Integer Dim strSQL As String Set rs = CurrentDb.OpenRecordset("OutlookImport") Set outObject = CreateObject("Outlook.Application") Set Mapi = outObject.GetNamespace("MAPI") Set Inbox = Mapi.GetDefaultFolder(olFolderInbox).Folders("import") Set InboxImported = Mapi.GetDefaultFolder(olFolderInbox).Folders("imported") For Each Mail In Inbox.Items strSQL = "INSERT INTO OutlookImport (AbsenderMail, AbsenderName, SendTo, SendCC, Betreff, MailDatum, Nachricht, EntryID) VALUES ('" & Mail.SenderEmailAddress & "', '" & Mail.SenderName & "', '" & Mail.To & "', '" & Mail.CC & "', '" & Mail.Subject & "', '" & Mail.SentOn & "', '" & Mail.Body & "', '" & Mail.EntryID & "');" DoCmd.SetWarnings False On Error Resume Next DoCmd.RunSQL strSQL DoCmd.SetWarnings True If Not Err.Number <> 0 Then Mail.Move InboxImported End If Next Forms![OutlookImport].Requery End Sub
Actually it works, but there are a lot of mails generate an error. I can handle that with the "On Error Resume Next" but so I lost many mails to move and I want to know why the error happens.
the protocol shows me the following error message: "Syntax error (missing Operator)" and Err.Description shows me the content of the mail.
can anybody help me with that strange stuff or has an idea? It would be helpful.
thx