Note: The other languages of the website are Google-translated. Back to English

Como salvar mensagem de e-mail como formato de imagem (jpg / tiff) no Outlook?

Você já tentou salvar uma mensagem de e-mail como uma imagem, como jpg ou tiff no Outlook? Este artigo mostrará um método para resolver esse problema.

Salve a mensagem de e-mail como formato de imagem com código VBA


Salve a mensagem de e-mail como formato de imagem com código VBA

Faça o seguinte para salvar uma mensagem de e-mail como formato de imagem no Outlook.

1. Selecione um e-mail que você salvará como imagem e pressione o botão outro + F11 simultaneamente para abrir o Microsoft Visual Basic para Aplicações janela.

2. No Microsoft Visual Basic para Aplicações janela, por favor clique inserção > UserForm. Veja a imagem:

3. Crie um Formulário de usuário como a imagem abaixo mostrada.

4. Selecione a Opção jpg botão e mude seu nome para opbJPG no lado esquerdo Propriedades painel.

5. Repita a etapa 4 acima para renomear o outro botão de opções como opbTIFF. E renomear o OK botão de comando e o Cancelar botão de comando como cdbOk e cdbCancelar separadamente.

Nota: Se o Propriedades painel não mostra no Microsoft Visual Basic para Aplicações janela, por favor clique no F4 para abrir o painel.

6. Clique duas vezes em qualquer espaço em branco no formulário do usuário para abrir o Código janela. Substitua todo o código pelo seguinte script VBA. E feche a janela de código.

Código VBA 1: Salvar mensagem de e-mail como imagem

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. Select the UserForm1 and change its name to FrmPicType in the Properties pane as below screenshot shown.

8. Click Insert > Module, and then copy the below VBA code into the Module window.

VBA code 2: Save email message as picture

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. Click Tools > References, check the Microsoft PowerPoint Object Library box and then click the OK button. See screenshot:

10. Press the F5 key to run the code. Then the UserForm1 dialog box pops up, please select a picture type and click the OK button. See screenshot:

11. In the Browse For Folder dialog box, specify a folder to save the picture, and then click the OK button.

12. Finally, a Microsoft Outlook dialog box will display to tell you about the completion of the saving. Please click the OK button.

Now the selected emails are converted to a jpg or tiff picture and saved into a specified folder successfully.


Related Articles:


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations

Follow Us

Copyright © 2009 - www.extendoffice.com. | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL