跳至主要内容

Kutools for Office — 一套工具,五种功能。事半功倍。

如何在Outlook中将邮件保存为图片格式(jpg/tiff)?

Author Siluvia Last modified

您是否曾经尝试过在Outlook中将电子邮件保存为jpg或tiff格式的图片?本文将向您展示一种解决此问题的方法。

使用VBA代码将电子邮件保存为图片格式


使用VBA代码将电子邮件保存为图片格式

请按照以下步骤将电子邮件保存为Outlook中的图片格式。

1. 选择要保存为图片的电子邮件,然后同时按Alt + F11键以打开Microsoft Visual Basic for Applications窗口。

2. 在Microsoft Visual Basic for Applications 窗口中,请点击插入 > 用户窗体。参见截图:

steps on saving email message as picture format (jpg/tiff) in outlook

3. 创建一个如下截图所示的用户窗体

steps on saving email message as picture format (jpg/tiff) in outlook

4. 选择jpg选项按钮,并将其名称更改为opbJPG(在左侧属性窗格中)。

steps on saving email message as picture format (jpg/tiff) in outlook

5. 重复上述步骤4,将其他选项按钮重命名为opbTIFF。并将“确定”命令按钮和“取消”命令按钮分别重命名为cdbOk cdbCancel

注意:如果在Microsoft Visual Basic for Applications窗口中未显示属性窗格,请按F4键以显示该窗格。

6. 双击用户窗体上的任意空白处以打开代码窗口。用以下VBA脚本替换所有代码。然后关闭代码窗口。

VBA代码1:将电子邮件保存为图片

Option Explicit
'Update by Extendoffice 2018/3/5
Public xRet As Boolean
Private Sub cdbCancel_Click()
  xRet = False
  FrmPicType.Hide
End Sub
Private Sub cdbOk_Click()
  xRet = True
  FrmPicType.Hide
End Sub

7. 选择UserForm1,并将其名称更改为FrmPicType (在属性窗格中),如下截图所示。

steps on saving email message as picture format (jpg/tiff) in outlook

8. 点击插入 > 模块,然后将下面的VBA代码复制到模块窗口中。

VBA代码2:将电子邮件保存为图片

Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'Update by Extendoffice 2018/3/5
Sub ExportEmailAsImage()
Dim xMail As Outlook.MailItem
Dim xFileName, xFilePath, xWdDocPath As String
Dim xPPTApp As PowerPoint.Application
Dim xPresentation As PowerPoint.Presentation
Dim xPPTShape As PowerPoint.Shape
Dim xPicType As String
Dim xFileFormat As PpSaveAsFileType
On Error Resume Next
FrmPicType.Show
If FrmPicType.xRet Then
  If FrmPicType.opbJPG.Value = True Then
    xPicType = ".jpg"
    xFileFormat = ppSaveAsJPG
  ElseIf FrmPicType.opbTIFF.Value = True Then
    xPicType = ".tiff"
    xFileFormat = ppSaveAsTIF
  End If
Else
  Exit Sub
End If
Set xShell = CreateObject("Shell.Application")
Set xFolder = xShell.BrowseForFolder(0, "Select a folder:", 0, 0)
If Not TypeName(xFolder) = "Nothing" Then
    Set xFolderItem = xFolder.self
    xFilePath = xFolderItem.Path & "\"
Else
    xFilePath = ""
    Exit Sub
End If
'ShellExecute 0, "Open", "POWERPNT.exe", "", "", 0
Set xPPTApp = New PowerPoint.Application
xPPTApp.Height = 0
xPPTApp.Width = 0
xPPTApp.WindowState = ppWindowMinimized
xPPTApp.Visible = msoFalse
For Each xMail In Outlook.Application.ActiveExplorer.Selection
    xFileName = Replace(xMail.Subject, "/", " ")
    xFileName = Replace(xFileName, "\", " ")
    xFileName = Replace(xFileName, ":", "")
    xFileName = Replace(xFileName, "?", " ")
    xFileName = Replace(xFileName, Chr(34), " ")
    xWdDocPath = Environ("Temp") & "\" & xFileName & ".doc"
    xMail.SaveAs xWdDocPath, olDoc
    
    Set xPresentation = xPPTApp.Presentations.Add
    xPresentation.Application.WindowState = ppWindowMinimized
    xPresentation.Application.Visible = msoFalse
    With xPresentation
        .PageSetup.SlideHeight = 900 '792
        .PageSetup.SlideWidth = 612
        .Slides.AddSlide 1, .SlideMaster.CustomLayouts(1)
    End With
    xPPTApp.WindowState = ppWindowMinimized
    With xPresentation.Slides(1)
         .Application.Visible = msoFalse
         Set xPPTShape = .Shapes.AddOLEObject(0, 0, 612, 900, , xWdDocPath)
         xPresentation.SaveAs xFilePath & xFileName & xPicType, xFileFormat, msoTrue
    End With
    xPresentation.Close
Next
xPPTApp.Quit
MsgBox "Mails has been successfully saved as picture", vbInformation + vbOKOnly
End Sub

9. 点击工具 > 引用,勾选Microsoft PowerPoint对象库复选框,然后点击确定按钮。参见截图:

steps on saving email message as picture format (jpg/tiff) in outlook

10. 按F5键运行代码。然后弹出UserForm1对话框,请选择一种图片类型并点击确定按钮。参见截图:

steps on saving email message as picture format (jpg/tiff) in outlook

11. 在“浏览文件夹”对话框中,指定一个文件夹以保存图片,然后点击确定按钮。

steps on saving email message as picture format (jpg/tiff) in outlook

12. 最后,会显示一个Microsoft Outlook对话框,告诉您保存已完成。请点击确定按钮。

steps on saving email message as picture format (jpg/tiff) in outlook

现在,所选电子邮件已成功转换为jpg或tiff图片并保存到指定文件夹中。


相关文章:


最佳 Office 办公效率工具

最新消息:Kutools for Outlook 推出免费版!

体验全新 Kutools for Outlook,超过100 种强大功能!立即点击下载!

🤖 Kutools AI 采用先进的 AI 技术,轻松处理邮件,包括答复、总结、优化、扩展、翻译和撰写邮件。

📧 邮箱自动化自动答复(支持 POP 和 IMAP) /计划发送邮件 /发送邮件时按规则自动抄送密送 / 自动转发(高级规则) / 自动添加问候语 / 自动将多收件人的邮件分割为单独邮件 ...

📨 邮件管理撤回邮件 / 按主题及其他条件阻止欺诈邮件 / 删除重复邮件 / 高级搜索 / 整合文件夹 ...

📁 附件增强批量保存 / 批量拆离 / 批量压缩 / 自动保存 / 自动拆离 / 自动压缩 ...

🌟 界面魔法😊更多美观酷炫的表情 /重要邮件到达时提醒 / 最小化 Outlook 而非关闭 ...

👍 一键高效操作带附件全部答复 / 防钓鱼邮件 / 🕘显示发件人时区 ...

👩🏼‍🤝‍👩🏻 联系人与日历批量添加选中邮件中的联系人 / 分割联系人组为单独的组 / 移除生日提醒 ...

可根据您偏好选择 Kutools 使用语言——支持英语、西班牙语、德语、法语、中文及40 多种其他语言!

只需点击一下即可立即激活 Kutools for Outlook。无需等待,立即下载,提升工作效率!

kutools for outlook features1 kutools for outlook features2

🚀 一键下载——获取所有 Office 插件

强烈推荐:Kutools for Office(五合一)

一键下载五个安装包Kutools for Excel、Outlook、Word、PowerPoint以及 Office Tab Pro 立即点击下载!

  • 一键便利操作:一次下载全部五个安装包。
  • 🚀 随时满足 Office任务需求:需要哪个插件随时安装即可。
  • 🧰 包含:Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint