问题描述
我正在尝试提取.msg文件中的zip文件附件,这些附件均保存在我的一个驱动器文件夹中。我发现这个thread讨论了这个问题,但是在“ Sub”行中我一直收到“未定义用户定义的类型”错误,我不清楚原因。据我所知,这些引用是正确的,但我不知道它是否与某个驱动器有关,或者是否需要添加另一行代码。对于这个问题,我是VBA和stackoverflow的新手,我想做的终点是提取和转换文件,从.msg中获取时间戳,并将其添加为压缩文件中的一列。任何帮助将不胜感激!
谢谢!
Sub SaveOlAttachments()
Dim app As Outlook.Application
Dim msg As Outlook.MailItem
Dim att As Outlook.Attachment
Dim strFilePath As String
Dim strAttPath As String
'path for creating msgs
strFilePath = "C:\Users\xxxxxxx\OneDrive\foldername1"
'path for saving attachments
strAttPath = "C:\Users\xxxxxxx\OneDrive\foldername2"
strFile = Dir(strFilePath & "*.msg")
Do While Len(strFile) > 0
Set msg = app.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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)