sans_souciの日記

無憂茶房

excel/vba から outlook にアクセスする方法(GetDefaultFolder(6) 無しで)

VBA/Excel から Outlook のメールボックスに保存されているメールを取得する方法(GetDefaultFolder(6) 無しで)

絶賛準備中

書き込みできてない点は次のとおり:

  • メールをテキストに書き出す操作
  • 特定のディレクトリにアクセスする操作

以下 内訳

Private Sub CommandButton1_Click()

  Set objoutlook = New Outlook.Application
  Set myNameSpace = objoutlook.GetNamespace("MAPI")
  
  p = 11
  r = 13
  
  For Each i In myNameSpace.Folders
    For Each j In i.Folders
      If j = "DIRECT" Then
        Cells(11, 1) = j
        Cells(11, 2) = j.Items.Count
        
        For Each k In j.Items
          Cells(r, 1) = k.Subject
          Cells(r, 2) = k.SenderName
          Cells(r, 3) = k.SenderEmailAddress
          Cells(r, 4) = Replace(k.Body, vbCrLf, "<br>")
          r = r + 1
        Next
      End If
    Next
'    For k = 1 To i.Folders.Count
'
'      Cells(10 + k, 1) = i.Folders(k)
'      result = i.Folders(k)
'      If result = "DIRECT" Then
'        Cells(11, 1) = result
'
'        Cells(12, 1) = i.Folders.Count
'      Else
'        Cells(10 + k, 1) = result
'      End If
  Next

End Sub

時間ががが・・ もどってきたらもう一度編集