【发布时间】:2023-01-07 02:20:14
【问题描述】:
我想从 outlook .msg 文件中读取附件。 我从此处找到的另一个解决方案复制了 VB 代码,但在“对于 msg.Attachments 中的每个 att”循环中,我收到错误“表达式的类型为‘附件’,这不是集合类型”。
我正在使用 Visual Studio 2019。 你能帮我吗?
Sub SaveAttachments()
Dim msg As Outlook.MailItem
Dim att As Outlook.Attachment
Dim strFilePath As String
Dim strAttPath As String
Dim strFile As String
strFilePath = "C:\Users\...\Desktop\Test\"
strAttPath = "C:\Users\...\extracted attachment\"
strFile = Dir(strFilePath & "<Doc Name>.msg")
Do While Len(strFile) > 0
msg = Application.CreateItemFromTemplate(strFilePath & strFile)
If msg.Attachments.Count > 0 Then
For Each att In msg.Attachments
att.SaveAsFile(strAttPath & att.FileName)
Next
End If
strFile = Dir()
Loop
End Sub
【问题讨论】:
标签: vb.net types foreach collections expression