0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

選択中のメールからConversationツリーの最初のメールを表示

Last updated at Posted at 2021-10-11

これを作りたい

第一歩として、メール一覧から、現在選択中のメールかの返信元をさかのぼり、親がなくなる最初のメールを開くものを作りました。

道中で見つかった各メールはmyParentsに格納していきます。

子メールさがし方向は分岐があるだけでなく、.GetConversation.GetChildren(CurItme).Item(1)と最初の要素だけを切り抜こうと思ってもうまく行かないので少し難易度が上がりそうです。。。

Sub Conversationツリーの最初のメールを表示()
  Dim CurItme As Outlook.MailItem
  Dim myParents() As Outlook.MailItem
  
  Set CurItme = ActiveExplorer.Selection.Item(1)
  With CurItme
    Dim k: k = 0
    ReDim myParents(k)
    Set myParents(k) = .GetConversation.GetParent(CurItme)
    
    Do Until myParents(k) Is Nothing
    
      Debug.Print k
      Debug.Print myParents(k).SentOn
      Debug.Print myParents(k).SenderName
      
      k = k + 1
      ReDim Preserve myParents(k)
      Set myParents(k) = .GetConversation.GetParent(myParents(k - 1))
    Loop
  End With
  
  myParents(k - 1).Display
  
End Sub
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?