共计 560 个字符,预计需要花费 2 分钟才能阅读完成。
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
测试代码
Private Sub Application_NewMail()
Dim objMail As Outlook.MailItem
Dim objAttachment As Outlook.Attachment
Dim strFolderPath As String
Dim i As Integer
' 指定保存附件的文件夹路径
strFolderPath = "C:\Attachments\"
Set objMail = Application.Session.GetDefaultFolder(olFolderInbox).Items.GetLast()
If objMail.Attachments.Count > 0 Then
For i = 1 To objMail.Attachments.Count
Set objAttachment = objMail.Attachments.Item(i)
objAttachment.SaveAsFile strFolderPath & objAttachment.DisplayName
Set objAttachment = Nothing
Next i
End If
Set objMail = Nothing
End Sub
正文完