KutoolsforOffice — Tek çözüm, beş güçlü araç.Daha az çabayla daha fazlasını başarmak.

Outlook’ta bir e-postayı ve eklerini tek bir PDF dosyası olarak nasıl dönüştürebilir veya kaydedebilirim?

YazarSiluvia Değiştirme Tarihi

Bu makale, Outlook’ta bir e-posta mesajını ve içerdiği tüm ekleri tek bir PDF dosyası olarak kaydetme işlemini açıklamaktadır.

E-posta ve ekleri tek bir PDF Dosyaları dosyasına VBA koduyla dönüştürün veya kaydedin


E-posta ve ekleri tek bir PDF Dosyaları dosyasına VBA koduyla dönüştürün veya kaydedin

Outlook'ta e-postayı ve tüm eklerini tek bir PDF dosyası olarak kaydetmek için aşağıdaki adımları izleyin.

1. Tek bir PDF dosyasına kaydetmek istediğiniz ekli e-postayı seçin ve ardından Alt+F11 tuşlarına basarak Microsoft Visual Basic for Applications penceresini açın.

2. Microsoft Visual Basic for Applications penceresinde, Ekle > Modül seçeneğine tıklayın. Ardından aşağıdaki VBA kodunu Modül penceresine kopyalayın.

VBA kodu: E-posta ve eki tek bir PDF Dosyaları dosyasına kaydedin

Public Sub MergeMailAndAttachsToPDF()
'Update by Extendoffice 2018/3/5
Dim xSelMails As MailItem
Dim xFSysObj As FileSystemObject
Dim xOverwriteBln As Boolean
Dim xLooper As Integer
Dim xEntryID As String
Dim xNameSpace As Outlook.NameSpace
Dim xMail As Outlook.MailItem
Dim xExt As String
Dim xSendEmailAddr, xCompanyDomain As String
Dim xWdApp As Word.Application
Dim xDoc, xNewDoc As Word.Document
Dim I As Integer
Dim xPDFSavePath As String
Dim xPath As String
Dim xFileArr() As String
Dim xExcel As Excel.Application
Dim xWb As Workbook
Dim xWs As Worksheet
Dim xTempDoc As Word.Document

On Error Resume Next
If (Outlook.ActiveExplorer.Selection.Count > 1) Or (Outlook.ActiveExplorer.Selection.Count = 0) Then
    MsgBox "Please Select a email.", vbInformation + vbOKOnly
    Exit Sub
End If
Set xSelMails = Outlook.ActiveExplorer.Selection.Item(1)
xEntryID = xSelMails.EntryID
Set xNameSpace = Application.GetNamespace("MAPI")
Set xMail = xNameSpace.GetItemFromID(xEntryID)

xSendEmailAddr = xMail.SenderEmailAddress
xCompanyDomain = Right(xSendEmailAddr, Len(xSendEmailAddr) - InStr(xSendEmailAddr, "@"))
xOverwriteBln = False
Set xExcel = New Excel.Application
xExcel.Visible = False
Set xWdApp = New Word.Application
xExcel.DisplayAlerts = False
xPDFSavePath = xExcel.Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="PDF Files(*.pdf),*.pdf")
If xPDFSavePath = "False" Then
    xExcel.DisplayAlerts = True
    xExcel.Quit
    xWdApp.Quit
    Exit Sub
End If
xPath = Left(xPDFSavePath, InStrRev(xPDFSavePath, "\"))
cPath = xPath & xCompanyDomain & "\"
yPath = cPath & Format(Now(), "yyyy") & "\"
mPath = yPath & Format(Now(), "MMMM") & "\"
If Dir(xPath, vbDirectory) = vbNullString Then
   MkDir xPath
End If
EmailSubject = CleanFileName(xMail.Subject)
xSaveName = Format(xMail.ReceivedTime, "yyyymmdd") & "_" & EmailSubject & ".doc"
Set xFSysObj = CreateObject("Scripting.FileSystemObject")
If xOverwriteBln = False Then
   xLooper = 0
  Do While xFSysObj.FileExists(yPath & xSaveName)
      xLooper = xLooper + 1
      xSaveName = Format(xMail.ReceivedTime, "yyyymmdd") & "_" & EmailSubject & "_" & xLooper & ".doc"
   Loop
Else
   If xFSysObj.FileExists(yPath & xSaveName) Then
      xFSysObj.DeleteFile yPath & xSaveName
   End If
End If
xMail.SaveAs xPath & xSaveName, olDoc
If xMail.Attachments.Count > 0 Then
   For Each atmt In xMail.Attachments
      xExt = SplitPath(atmt.filename, 2)
      If (xExt = ".docx") Or (xExt = ".doc") Or (xExt = ".docm") Or (xExt = ".dot") Or (xExt = ".dotm") Or (xExt = ".dotx") _
      Or (xExt = ".xlsx") Or (xExt = ".xls") Or (xExt = ".xlsm") Or (xExt = ".xlt") Or (xExt = ".xltm") Or (xExt = ".xltx") Then
        atmtName = CleanFileName(atmt.filename)
        atmtSave = xPath & Format(xMail.ReceivedTime, "yyyymmdd") & "_" & atmtName
        atmt.SaveAsFile atmtSave
      End If
   Next
End If
Set xNewDoc = xWdApp.Documents.Add("Normal", False, wdNewBlankDocument, False)
Set xFilesFld = xFSysObj.GetFolder(xPath)
xFileArr() = GetFiles(xPath)
For I = 0 To UBound(xFileArr()) - 1
    xExt = SplitPath(xFileArr(I), 2)
    If (xExt = ".xlsx") Or (xExt = ".xls") Or (xExt = ".xlsm") Or (xExt = ".xlt") Or _
       (xExt = ".xltm") Or (xExt = ".xltx") Then  'conver excel to word
        Set xWb = xExcel.Workbooks.Open(xPath & xFileArr(I))
        Set xTempDoc = xWdApp.Documents.Add("Normal", False, wdNewBlankDocument, False)
        Set xWs = xWb.ActiveSheet
        xWs.UsedRange.Copy
        xTempDoc.Content.PasteAndFormat wdFormatOriginalFormatting
        xTempDoc.SaveAs2 xPath & xWs.Name + ".docx", wdFormatXMLDocument
        xWb.Close False
        Kill xPath & xFileArr(I)
        xTempDoc.Close wdDoNotSaveChanges, wdOriginalDocumentFormat, False
    End If
Next
xExcel.DisplayAlerts = True
xExcel.Quit
xFileArr() = GetFiles(xPath)
'Merge Documents
For I = 0 To UBound(xFileArr()) - 1
    xExt = SplitPath(xFileArr(I), 2)
    If (xExt = ".docx") Or (xExt = ".doc") Or (xExt = ".docm") Or (xExt = ".dot") Or _
       (xExt = ".dotm") Or (xExt = ".dotx") Then
        MergeDoc xWdApp, xPath & xFileArr(I), xNewDoc
        Kill xPath & xFileArr(I)
    End If
Next
xNewDoc.Sections.Item(1).Range.Delete wdCharacter, 1
xNewDoc.SaveAs2 xPDFSavePath, wdFormatPDF
xNewDoc.Close wdDoNotSaveChanges, wdOriginalDocumentFormat, False
xWdApp.Quit
Set xMail = Nothing
Set xNameSpace = Nothing
Set xFSysObj = Nothing
MsgBox "Merged successfully", vbInformation + vbOKOnly
End Sub

Public Function SplitPath(FullPath As String, ResultFlag As Integer) As String
Dim SplitPos As Integer, DotPos As Integer
SplitPos = InStrRev(FullPath, "/")
DotPos = InStrRev(FullPath, ".")
Select Case ResultFlag
Case 0
   SplitPath = Left(FullPath, SplitPos - 1)
Case 1
   If DotPos = 0 Then DotPos = Len(FullPath) + 1
   SplitPath = Mid(FullPath, SplitPos + 1, DotPos - SplitPos - 1)
Case 2
   If DotPos = 0 Then DotPos = Len(FullPath)
   SplitPath = Mid(FullPath, DotPos)
Case Else
   Err.Raise vbObjectError + 1, "SplitPath Function", "Invalid Parameter!"
End Select
End Function
  
Function CleanFileName(StrText As String) As String
Dim xStripChars As String
Dim xLen As Integer
Dim I As Integer
xStripChars = "/\[]:=," & Chr(34)
xLen = Len(xStripChars)
StrText = Trim(StrText)
For I = 1 To xLen
StrText = Replace(StrText, Mid(xStripChars, I, 1), "")
Next
CleanFileName = StrText
End Function

Function GetFiles(xFldPath As String) As String()
On Error Resume Next
Dim xFile As String
Dim xFileArr() As String
Dim xArr() As String
Dim I, x As Integer
x = 0
ReDim xFileArr(1)
xFileArr(1) = xFldPath '& "\"
xFile = Dir(xFileArr(1) & "*.*")
Do Until xFile = ""
    x = x + 1
    xFile = Dir
Loop
ReDim xArr(0 To x)
x = 0
xFile = Dir(xFileArr(1) & "*.*")
Do Until xFile = ""
    xArr(x) = xFile
    x = x + 1
    xFile = Dir
Loop
GetFiles = xArr()
End Function

Sub MergeDoc(WdApp As Word.Application, xFileName As String, Doc As Document)
Dim xNewDoc As Document
Dim xSec As Section
    Set xNewDoc = WdApp.Documents.Open(filename:=xFileName, Visible:=False)
    Set xSec = Doc.Sections.Add
    xNewDoc.Content.Copy
    xSec.PageSetup = xNewDoc.PageSetup
    xSec.Range.PasteAndFormat wdFormatOriginalFormatting
    xNewDoc.Close
End Sub

3. Araçlar > Başvurular seçeneğine tıklayarak Başvurular iletişim kutusunu açın. Microsoft Excel Nesne Kitaplığı, Microsoft Scripting Runtime ve Microsoft Word Nesne Kitaplığı onay kutularını işaretleyin ve ardından Tamam düğmesine tıklayın. Ekran görüntüsüne bakın:

e-posta eklerini tek bir PDF olarak kaydetmeyle ilgili 1. adım

4. Kodu çalıştırmak için F5 tuşuna basın veya Çalıştır düğmesine tıklayın. Ardından bir Farklı Kaydet iletişim kutusu açılır; dosyayı kaydetmek için bir klasör belirtin, PDF Dosyaları dosyasına bir ad verin ve Kaydet düğmesine tıklayın. Ekran görüntüsüne bakın:

e-posta eklerini tek bir PDF olarak kaydetmeyle ilgili 2. adım

5. Ardından bir Microsoft Outlook iletişim kutusu açılır; lütfen Tamam düğmesine tıklayın.

e-posta eklerini tek bir PDF olarak kaydetmeyle ilgili 3. adım

Artık seçilen e-posta ve tüm ekleri tek bir PDF dosyasına kaydedildi.

Not: Bu VBA betiği yalnızca Microsoft Word ve Excel ekleriyle çalışır.


Seçili e-postaları Outlook'ta farklı biçimli dosyalar olarak kolayca kaydedin:

Toplu Kaydetyardımcı programıyla Kutools for Outlook, aşağıdaki ekran görüntüsünde gösterildiği gibi, seçili birden fazla e-postayı ayrı ayrı HTML Formatı dosyası, Txt Formatı dosyası, Word belgesi, CSV dosyası ve ayrıca PDF Dosyaları olarak Outlook'ta kolayca kaydedebilirsiniz.Kutools for Outlook'nin ücretsiz sürümünü hemen indirin!

e-posta eklerini tek bir PDF olarak kaydetmeyle ilgili 1. adım

İlgili Makaleler:


En İyi Office Verimlilik Araçları

Yepyeni Kutools for Outlook’i 100+ inanılmaz özelliğiyle deneyimleyin!Şimdi indirmek için tıklayın!

🤖KUTOOLS AI:E-postaları yanıtlama, özetleme, iyileştirme, uzatma, çevirme ve yazma dahil olmak üzere zahmetsizce yönetmek için gelişmiş yapay zeka teknolojisi kullanır.

📧E-posta Otomasyonu: Otomatik Yanıt (POP ve IMAP için kullanılabilir) / E-postaları Zamanlayarak Gönderme / E-posta Gönderirken Kurallara Göre Otomatik CC/BCC / Otomatik Yönlendirme (Gelişmiş Kurallar) / Otomatik Selam Eklemesi / Çok Alıcılı E-postaları Otomatik Olarak Bireysel Mesajlara Bölme…

📨E-posta Yönetimi: E-postayı Geri Çağırma, Konularına ve Diğer Özelliklerine Göre Dolandırıcılık E-postalarını Engelleme, Yinelenen E-postaları Silme, Gelişmiş Arama, Klasörleri Düzenleme…

📁Ekler Pro: Toplu Kaydetme, Toplu Ayırma, Toplu Sıkıştırma, Otomatik Kaydet, Otomatik Ayır ve Otomatik Sıkıştır…

🌟Arayüz Büyüsü: 😊 Daha Güzel ve Havalı Emojiler / Önemli e-postalar geldiğinde sizi uyarır / Outlook’u Kapatmak Yerine Küçültür…

👍Tek Tıklamayla Harikalar: Tümüne Eklerle Yanıtla / Phishing’e Karşı E-posta Koruma / 🕘Gönderenin Mevcut Saati ve Saat Dilimini Göster…

👩🏼‍🤝‍👩🏻Kişiler ve Takvim:Seçili E-postalardan Toplu Kişi Ekleme/Bir Kişi Grubunu Bireysel Gruplara Bölme/Doğum Günü Hatırlatıcısını Kaldırma…

Kutools’u tercih ettiğiniz dilde kullanın – İngilizce, İspanyolca, Almanca, Fransızca, Çince ve 40’tan fazla başka dili destekler!

Tek bir tıklamayla Kutools for Outlook’un kilidini hemen açın! Beklemeyin, şimdi indirin ve verimliliğinizi artırın!

kutools for outlook features1kutools for outlook features2

🚀 Tek Tıkla İndir — Tüm Office Eklentilerini Edinin

Kesinlikle Önerilir: Kutools for Office (5’li Paket)

Beş yükleyiciyi tek tıkla indirin beş yükleyiciyiaynı anda —Kutools for Excel, Outlook, Word, PowerPointve Office Tab Pro.Şimdi indirmek için tıklayın!

  • ✅Tek tıklamayla kullanım kolaylığı: Beş kurulum paketini tek bir işlemle indirin.
  • 🚀Her Office görevine hazır: İhtiyacınız olduğunda, ihtiyacınız olan eklentileri yükleyin.
  • 🧰İçerik: Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint