我有问题。我已经编写了该代码,并且在我更换计算机之前一切正常。
几周前,我什至回答了自己的问题:Copy Outlook mail (.msg) in windows folder
但是由于某些原因,我的代码无法完全正常工作。
它可以:
不能再做:
这是代码:
For Each i In fol.Items
If i.Class = olMail Then
Set mi = i
If mi.Attachments.Count > 0 Then
'creating folder name
dirName = "R:\ASP\test\" & Format(mi.ReceivedTime, "yyyy-mm-dd hh-nn-ss ") & Left(Replace(mi.Subject, ":", ""), 20)
If fso.FolderExists(dirName) Then
Set dir = fso.GetFolder(dirName)
Else
Set dir = fso.CreateFolder(dirName)
'adding copy of outlook mail
sName = mi.Subject
mi.SaveAs dirName & "\" & Format$(mi.CreationTime, "yyyymmdd_") & sName & ".msg"
End If
'adding .PDF files inside folder
For Each at In mi.Attachments
at.SaveAsFile dir.Path & "\" & at.FileName
Next at