17. marts 2016 - 13:26Der er
14 kommentarer og 1 løsning
Loop mails i flere mappe i Outlook 2013 via VBA
Hej, Jeg har brug for at have en tabel med mappenavne i Outlook. Dvs. både direkte mapper og undermapper. Jeg ønsker så via VBA at loope denne tabel igennem for derved at læse alle mails i alle mapperne, og derved hente diverse informationer fra hver mail.
Jeg kan bare ikke finde ud af hvordan jeg skriver koden i VBA???
Jeg kan godt finde ud af at lave et loop på en tabel, men kan ikke finde ud af at se ned i en specifik mappe.
Noget i denne retning:
Public Function Processmails() Dim oOutlook As Outlook.Application Dim oNs As Outlook.NameSpace Dim oFldr As Outlook.MAPIFolder Dim oAttachments As Outlook.Attachments Dim oAttachment As Outlook.Attachment Dim iMsgCount As Integer
Dim oMessage As Outlook.MailItem
Dim iCtr As Long, iAttachCnt As Long
Dim sFileNames As String Dim aFileNames() As String
'get reference to inbox Set oOutlook = New Outlook.Application Set oNs = oOutlook.GetNamespace("MAPI") Set oFldr = oNs.PickFolder.FolderPath("MinMailMappeIOutlook")
For Each oMessage In oFldr.Items
Set oAttachment = Nothing Set oAttachments = Nothing Set oMessage = Nothing Set oFldr = Nothing Set oNs = Nothing Set oOutlook = Nothing
Ja pt men jeg skal finde ud af det ønskede :-) Den mappe du ønsker via strengen kan den ligge på alle niveauer? Og er der en hovedmappen evt indbakken eller ?
Public Function Processmails() On Error GoTo err Dim oOutlook As Outlook.Application Dim oNs As Outlook.NameSpace Dim oFldr As Outlook.Folder Dim of As Object Dim oAttachments As Outlook.Attachments Dim oAttachment As Outlook.Attachment Dim iMsgCount As Integer Dim oMessage As Outlook.MailItem Dim iCtr As Long, iAttachCnt As Long
Const olFolderInbox = 6 'get reference to inbox Set oOutlook = New Outlook.Application Set oNs = oOutlook.GetNamespace("MAPI") Set of = oNs.GetDefaultFolder(olFolderInbox)
For Each oMessage In of.Items Debug.Print oMessage.ConversationID & " " & oMessage.EntryID Next Exit Function err: If err.Number = 13 Then Resume Next Debug.Print err.Description Resume Next End Function
Public Function Processmails() On Error GoTo err Dim oOutlook As Outlook.Application Dim oNs As Outlook.NameSpace Dim oFldr As Outlook.Folder Dim of As Object Dim oAttachments As Outlook.Attachments Dim oAttachment As Outlook.Attachment Dim iMsgCount As Integer Dim oMessage As Outlook.MailItem Dim iCtr As Long, iAttachCnt As Long
Const olFolderInbox = 6 'get reference to inbox Set oOutlook = New Outlook.Application Set oNs = oOutlook.GetNamespace("MAPI") Set of = oNs.GetDefaultFolder(olFolderInbox).Parent.Folders("GPD")
For Each oMessage In of.Items Debug.Print oMessage.ConversationID & " " & oMessage.EntryID Next Exit Function err: If err.Number = 13 Then Resume Next Debug.Print err.Description Resume Next End Function
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.