如果您希望Outlook自動從特定的傳入電子郵件中提取並保存嵌入的圖像,則可以參考本文。 在這裡,我們將教您如何使用VBA代碼實現它。
一些用戶經常需要從特定的傳入電子郵件中提取嵌入的圖像,並將其保存到某個Windows文件夾中。 每次手動進行操作都非常麻煩。 因此,許多人期望學習一種快速便捷的方法來讓Outlook自動完成此任務。 現在,我們將在這裡與您分享這種方法。
自動從特定的傳入電子郵件中提取嵌入式圖像
- 首先,像往常一樣啟動Outlook程序。
- 然後,像往常一樣使用“ t”觸發Outlook VBA編輯器如何在Outlook中運行VBA代碼“。
- 稍後,將以下VBA代碼複製並粘貼到“ ThisOutlookSession”項目中。
Public WithEvents objInbox As Outlook.Folder
Public WithEvents objInboxItems As Outlook.Items
Private Sub Application_Startup()
Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
Set objInboxItems = objInbox.Items
End Sub
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
Dim objMail As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objAttachment As Outlook.Attachment
Dim strWindowsFolder As String
Dim i As Long
If TypeOf Item Is MailItem Then
Set objMail = Item
'Specify the emails as per your needs
If objMail.Importance = olImportanceHigh Then
Set objAttachments = objMail.Attachments
'Specify the windows folder
strWindowsFolder = "E:\" & objMail.Subject & Format(Now, "yymmddhhmmss")
MkDir (strWindowsFolder)
'Save all embedded images to the folder
For i = 1 To objAttachments.Count
Set objAttachment = objAttachments.Item(i)
If IsEmbedded(objAttachment) = True Then
objAttachment.SaveAsFile strWindowsFolder & "\" & objAttachment.FileName
End If
Next
End If
End If
End Sub
Function IsEmbedded(objCurAttachment As Outlook.Attachment) As Boolean
Dim objPropertyAccessor As Outlook.PropertyAccessor
Dim strProperty As String
Set objPropertyAccessor = objCurAttachment.PropertyAccessor
strProperty = objPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E")
If InStr(1, strProperty, "@") > 0 Then
IsEmbedded = True
Else
IsEmbedded = False
End If
End Function
- 之後,點選進入「Application_Startup」子程式。
- 最後,單擊“ F5”鍵觸發該宏。
- 從現在開始,每次當特定的新電子郵件到達收件箱時,嵌入的圖像將被保存到特定的Windows文件夾中,如以下屏幕快照所示。
定期清理大型附件
建議您定期清理 Outlook 中的大型附件,以保持 Outlook 檔案大小適宜。較大的 Outlook 檔案更容易損壞。眾所周知,PST 檔案損壞很難徹底修復。您可能會先嘗試使用收件匣修復工具進行修復,但大多數情況下都無法奏效。您唯一的辦法是尋求專業的 Outlook 修復服務。 PST維修 工具,例如 DataNumen Outlook Repair,或相關的專業恢復服務。
作者簡介:
Shirley Zhang是的數據恢復專家 DataNumen,Inc.是數據恢復技術的全球領導者,包括 mdf修復 和Outlook修復軟件產品。 欲了解更多信息,請訪問 萬維網。datanumen.COM

