Hallo!
Ich versuche Emaildaten wie z.b. Sender, Datum, Thema usw aus Outlook auszulesen und in bestehende Tabellen einzupflegen. Leider habe ich keine VBA Kenntnisse und habe somit mehr durch probieren und c&p was zusammengebastelt. Kann mir einer helfen oder evtl sagen, wo ich so ein script finden kann?
Dim AF As Outlook.MAPIFolder
Sub ImportContactsFromOutlook()
Dim olApp As New Outlook.Application
Dim olNS As Outlook.NameSpace
Dim MyPostfach, MyFolder As Outlook.MAPIFolder
Dim MyMail As Outlook.MailItem ' wie in excel
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set AF = olNS.Folders(2)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblContacts")
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Dim O As Outlook.MailItem
Dim F As Outlook.MAPIFolder
Dim i As Long
For i = 1 To F.Items.Count
If F.Items(i).Class = olMail Then
Set O = F.Items(i)
With rst
.AddNew
!FirstName = O.FName
End With
End If
Next i
rst.Close
MsgBox "Finished"
End Sub |