本文介绍了列出附件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这次考试中,我获得了草稿数据中电子邮件的附件文件"编号.
In this exam I get the number of "attachment file" for an email in draft data.
有什么方法可以在msgbox或combobox或其他任何内容中获取此文件的名称?
Is there any way to get the name of this file in a msgbox or combobox or anything?
Private Sub CommandButton2_Click()
Dim a As Attachments
Dim myitem As Folder
Dim myitem1 As MailItem
Set myitem = Session.GetDefaultFolder(olFolderDrafts)
Dim i As Integer
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
End If
Next
End Sub
推荐答案
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
这篇关于列出附件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!