and again. I know itīs late and I should go to bed but I want solve this part. So if you can take an eye on this.
as in some threads before I have the following code:
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
If Mail.Attachments.Count > 0 Then
AnzAttach = Mail.Attachments.Count
strPath = "C:\Unterlagen\" & Replace(Mail.SenderName, " ", "") & "_" & Replace(Replace(Mail.SentOn, " ", "_"), ":", ".")
Debug.Print strPath
MkDir strPath
For i = 1 To AnzAttach
Mail.Attachments.Item(i).SaveAs strPath & Mail.Attachments.Item(i).FileName
Next i
strSQLAtt = "UPDATE OutlookImport SET AttachFolder = '" & strPath & "' WHERE AbsenderMail = '" & Mail.SenderEmailAddress & "'"
CurrentDb.Execute strSQLAtt
End If
Mail.Move InboxInBearbeitung 'Mails verschieben in Bearbeitung
End If
Next
Forms![OutlookImport].Requery
End Sub
I want to import the path to the Attachments I import before or put into a folder
I add an UPDATE sql statement but it donīt work correctly. I get on every record the same string (the same folder).
what is wrong?