Loncat ke daftar isi utama

Bagaimana cara mengekspor email dari Outlook ke Excel secara otomatis?

Biasanya, Anda dapat mengekspor email dari Outlook ke Excel dengan fitur Impor / Ekspor. Tapi, pernahkah Anda mencoba mengekspor email ke file Excel secara otomatis ketika pesan baru datang? Pada artikel ini, saya akan berbicara tentang cara mengekspor informasi pesan masuk baru secara otomatis di Excel.

Ekspor otomatis informasi email dari Outlook ke Excel dengan kode VBA

Ekspor informasi email dari Outlook ke Excel dengan fitur luar biasa


Ekspor otomatis informasi email dari Outlook ke Excel dengan kode VBA

Untuk mengekspor email baru yang tiba ke buku kerja Excel secara otomatis, harap terapkan kode VBA berikut:

1. Pertama, Anda harus membuat buku kerja dengan informasi header di bawah ini seperti gambar berikut yang diperlihatkan, sehingga informasi pesan ini akan diekspor ke file Excel ini.

doc otomatis mengekspor email ke excel 1

2. Lalu buka Outlook dan tahan file ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

3. di Microsoft Visual Basic untuk Aplikasi jendela, klik dua kali Sesi Pandangan ini dari Project1 (VbaProject.OTM) panel untuk membuka mode, lalu salin dan tempel kode berikut ke dalam modul kosong.

Kode VBA: Secara otomatis mengekspor informasi email dari Outlook ke file Excel:

Public WithEvents GMailItems As Outlook.Items
Private Sub Application_Startup()
    Set GMailItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub GMailItems_ItemAdd(ByVal Item As Object)
    Dim xMailItem As Outlook.MailItem
    Dim xExcelFile As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Excel.Workbook
    Dim xWs As Excel.Worksheet
    Dim xNextEmptyRow As Integer
    On Error Resume Next
    If Item.Class <> olMail Then Exit Sub
    Set xMailItem = Item
    xExcelFile = "C:\Users\DT168\Desktop\split document\kto-data.xlsx"
    If IsWorkBookOpen(xExcelFile) = True Then
        Set xExcelApp = GetObject(, "Excel.Application")
        Set xWb = GetObject(xExcelFile)
        If Not xWb Is Nothing Then xWb.Close True
    Else
        Set xExcelApp = New Excel.Application
    End If
    Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
    Set xWs = xWb.Sheets(1)
    xNextEmptyRow = xWs.Range("B" & xWs.Rows.Count).End(xlUp).Row + 1
    With xWs
        .Cells(xNextEmptyRow, 1) = xNextEmptyRow - 1
        .Cells(xNextEmptyRow, 2) = xMailItem.SenderName
        .Cells(xNextEmptyRow, 3) = xMailItem.SenderEmailAddress
        .Cells(xNextEmptyRow, 4) = xMailItem.Subject
        .Cells(xNextEmptyRow, 5) = xMailItem.ReceivedTime
    End With
    xWs.Columns("A:E").AutoFit
    xWb.Save
End Sub
Function IsWorkBookOpen(FileName As String)
    Dim xFreeFile As Long, xErrNo As Long
    On Error Resume Next
    xFreeFile = FreeFile()
    Open FileName For Input Lock Read As #xFreeFile
    Close xFreeFile
    xErrNo = Err
    On Error GoTo 0
    Select Case xErrNo
        Case 0: IsWorkBookOpen = False
        Case 70: IsWorkBookOpen = True
        Case Else: Error xErrNo
    End Select
End Function

Note: Pada kode di atas, C: \ Users \ DT168 \ Desktop \ split dokumen \ kto-data.xlsx adalah jalur file Excel dan nama Excel yang ingin Anda cari informasi yang diekspor, harap ubah sesuai kebutuhan Anda.

doc otomatis mengekspor email ke excel 2

4. Masih di Microsoft Visual Basic untuk Aplikasi window, klik Tools > Referensi untuk pergi ke Referensi-Proyek 1 kotak dialog, dan centang Perpustakaan Objek Microsoft Excel pilihan dari Referensi yang Tersedia kotak daftar, lihat tangkapan layar:

doc otomatis mengekspor email ke excel 3

5. Lalu klik OK untuk menutup dialog, lalu simpan dan tutup jendela kode.

6. Sekarang, Anda harus memulai ulang Outlook agar kode ini berlaku. Mulai sekarang, jika ada email baru yang masuk, mereka akan diekspor ke buku kerja tertentu secara otomatis, lihat tangkapan layar:

doc otomatis mengekspor email ke excel 4


Ekspor informasi email dari Outlook ke Excel dengan fitur luar biasa

Jika Anda ingin mengekspor email dari Kotak Masuk, Kotak Keluar, atau folder lain ke file Excel, Kutools untuk Outlook's Laporan Cepat dapat membantu Anda membuat file XML dengan mudah untuk melaporkan informasi semua item di folder email saat ini atau folder tugas yang Anda butuhkan.

Catatan:Untuk menerapkan ini Laporan Cepat, pertama, Anda harus mengunduh Kutools untuk Outlook, lalu terapkan fitur dengan cepat dan mudah.

Setelah menginstal Kutools untuk Outlook, lakukan seperti ini:

1. Pilih folder yang Anda inginkan untuk mengekspor semua informasi pesan, dan kemudian klik Kutools Ditambah > Laporan Cepat, lihat tangkapan layar:

2. Lalu, di pop out Menyimpan laporan jendela, pilih lokasi dan tentukan nama untuk file yang diekspor ini, lihat tangkapan layar:

3. Dan kemudian, klik Save untuk menyimpan file ini, dan di kotak yang muncul, klik Yes tombol untuk membuka file, lihat tangkapan layar:

4. Sekarang, Anda dapat melihat semua informasi email di folder yang dipilih telah diekspor ke file Excel, lihat tangkapan layar:


Artikel yang lebih relatif:

  • Ekspor Tabel Isi Email Ke Excel Di Outlook
  • Saat Anda menerima email yang berisi beberapa tabel di badan, terkadang, Anda mungkin perlu mengekspor semua tabel dari badan pesan ke lembar kerja excel. Biasanya, Anda dapat menyalin dan menempel tabel ke lembar kerja, tetapi, di sini, saya akan berbicara tentang metode yang berguna untuk menyelesaikan pekerjaan ini saat ada beberapa tabel yang perlu diekspor.
  • Ekstrak atau Ekspor Daftar Tugas ke Excel Di Outlook
  • Saat menggunakan Outlook, Anda bisa mengekstrak daftar tugas ke Excel untuk penggunaan lain. Dengan fitur Ekspor yang kuat di Outlook, Anda dapat dengan mudah mengekspor daftar tugas Anda ke Excel. Silakan lakukan seperti yang ditunjukkan tutorial di bawah ini.
  • Ekspor Informasi Kontak Dengan Foto Di Outlook
  • Saat Anda mengekspor kontak dari Outlook ke file, hanya informasi teks dari kontak yang dapat diekspor. Namun, terkadang, Anda memerlukan foto untuk diekspor serta informasi teks kontak, bagaimana Anda bisa menangani tugas ini di Outlook?

Alat Produktivitas Kantor Terbaik

Kutools untuk Outlook - Lebih dari 100 Fitur Canggih untuk Meningkatkan Outlook Anda

🤖 Asisten Surat AI: Email profesional instan dengan keajaiban AI--satu klik untuk mendapatkan balasan jenius, nada sempurna, penguasaan multibahasa. Ubah email dengan mudah! ...

📧 Email Otomatis: Di Luar Kantor (Tersedia untuk POP dan IMAP)  /  Jadwal Kirim Email  /  Auto CC/BCC Sesuai Aturan Saat Mengirim Email  /  Penerusan Otomatis (Aturan Lanjutan)   /  Tambah Salam Otomatis   /  Secara Otomatis Membagi Email Multi-Penerima menjadi Pesan Individual ...

📨 email Management: Mengingat Email dengan Mudah  /  Blokir Email Penipuan berdasarkan Subjek dan Lainnya  /  Hapus Email Duplikat  /  Pencarian  /  Konsolidasi Folder ...

📁 Lampiran ProPenyimpanan Batch  /  Pelepasan Batch  /  Kompres Batch  /  Penyimpanan otomatis   /  Lepaskan Otomatis  /  Kompres Otomatis ...

🌟 Antarmuka Ajaib: 😊Lebih Banyak Emoji Cantik dan Keren   /  Tingkatkan Produktivitas Outlook Anda dengan Tampilan Tab  /  Minimalkan Outlook Daripada Menutup ...

👍 Keajaiban sekali klik: Balas Semua dengan Lampiran Masuk  /   Email Anti-Phishing  /  🕘Tampilkan Zona Waktu Pengirim ...

👩🏼‍🤝‍👩🏻 Kontak & Kalender: Batch Tambahkan Kontak Dari Email yang Dipilih  /  Bagi Grup Kontak menjadi Grup Individual  /  Hapus Pengingat Ulang Tahun ...

Lebih 100 Fitur Tunggu Eksplorasi Anda! Klik Di Sini untuk Menemukan Lebih Banyak.

 

 

Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
If I have more than one email accounts in outlook, how can I output the emails from a specified account ?
This comment was minimized by the moderator on the site
I have followed above steps but have blanks in excel.
what should I do?
This comment was minimized by the moderator on the site
Same excel not getting updated? Any suggestions?
This comment was minimized by the moderator on the site
How to capture the Categories, Importance or the User-defined column on the same folder view?
This comment was minimized by the moderator on the site
Can you please let me know how to deal with sub-folders in above code.
This comment was minimized by the moderator on the site
how to deal with subfolders.
This comment was minimized by the moderator on the site
I need the help about exporting Email information sent (outgoing) emails
This comment was minimized by the moderator on the site
Hello, Jorge,
If you want to export the sent messages from the Sent Items folder, the Kutools for Outlook's Quick Report feature can help you. You can download the Kutools for Outlook first and then apply it.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations