MS Outlook 2010 如何缩小附加邮件中的图片大小

MS Outlook 2010 how to reduce picture size in attached messages

我有超过 1000 封电子邮件,其中都附有大尺寸图片,我想缩小这些尺寸(例如 1024x800 文档尺寸)。

通常我做的是在编辑模式下打开消息,然后打开图片,然后缩小尺寸,最后保存消息,这是一个很长的过程。

所以我在 vba 中寻找类似的东西 Save and remove attachments from email items (VBA)

Sub SaveAttachment() 
'Declaration
Dim myItems, myItem, myAttachments, myAttachment As Object
Dim myOrt As String
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection

'Ask for destination folder
myOrt = InputBox("Destination", "Save Attachments", "C:\")

On Error Resume Next

'work on selected items
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection

'for all items do...
For Each myItem In myOlSel

    'point on attachments
    Set myAttachments = myItem.Attachments

    'if there are some...
    If myAttachments.Count > 0 Then

        'add remark to message text
        myItem.Body = myItem.Body & vbCrLf & _
            "Removed Attachments:" & vbCrLf

        'for all attachments do...
        For i = 1 To myAttachments.Count

            'save them to destination
            myAttachments(i).SaveAsFile myOrt & _
                myAttachments(i).DisplayName

            'add name and destination to message text
            myItem.Body = myItem.Body & _
                "File: " & myOrt & _
                myAttachments(i).DisplayName & vbCrLf

        Next i

        'for all attachments do...
        While myAttachments.Count > 0

            'remove it (use this method in Outlook XP)
            'myAttachments.Remove 1

            'remove it (use this method in Outlook 2000)
            myAttachments(1).Delete

        Wend

        'save item without attachments
        myItem.Save
    End If

Next

'free variables
Set myItems = Nothing
Set myItem = Nothing
Set myAttachments = Nothing
Set myAttachment = Nothing
Set myOlApp = Nothing
Set myOlExp = Nothing
Set myOlSel = Nothing

End Sub

注意:我必须将大图片保留至少一个月,之后我想减小图片尺寸,所以我无法设置接收较小尺寸电子邮件的任何选项。

Outlook 对象模型不提供任何用于即时编辑附件的功能。但是,作为一种解决方法,您可以使用低级 属性 来获取表示附加文件的字节数组的设置。 PropertyAccessor class from the Outlook object model (see the corresponding property of the Attachment class) can be used for retrieving the PR_ATTACH_DATA_BIN 属性 值。 DASL 名称是 "http://schemas.microsoft.com/mapi/proptag/0x37010102"

Outlook 对象模型允许使用附件 class 的 SaveAsFile method of the Attachment class, do the required changes and re-attach it anew using the Add 方法将附件保存在磁盘上。