List the filenames of attachments

前端 未结 1 850
天命终不由人
天命终不由人 2021-01-15 06:47

In this exam I get the number of \"attachment file\" for an email in draft data.

Is there any way to get the name of this file in a msgbox or combobox or anything?<

1条回答
  •  再見小時候
    2021-01-15 07:43

    Private Sub CommandButton2_Click()
    
    Dim a As Attachments
    Dim myitem As Folder
    Dim myitem1 As MailItem
    Dim j As Long
    Dim i As Integer
    
    Set myitem = Session.GetDefaultFolder(olFolderDrafts)
    
    For i = 1 To myitem.Items.Count
      If myitem.Items(i) = test1 Then
        Set myitem1 = myitem.Items(i)
        Set a = myitem1.Attachments
    
        MsgBox a.Count
    
        ' added this code
        For j = 1 To myitem1.Attachments.Count
          MsgBox myitem1.Attachments.Item(i).DisplayName ' or .Filename
        Next j
    
      End If
    Next i
    End Sub
    

    0 讨论(0)
提交回复
热议问题