Loncat ke daftar isi utama

Bagaimana cara memindahkan email ke folder tertentu setelah menetapkan kategori tertentu di Outlook?

Misalkan Anda menetapkan kategori ke email yang diterima di Outlook Anda, setelah menetapkan kategori, Anda ingin email ini dipindahkan secara otomatis ke folder email tertentu yang diberi nama dengan nama kategori. Misalnya, email yang ditetapkan dengan kategori "Pribadi" akan dipindahkan ke nama folder "Pribadi" di Outlook Anda. Bagaimana cara mencapainya? Metode dalam artikel ini dapat membantu Anda menyelesaikan masalah dengan mudah.

Pindahkan email ke folder tertentu setelah menetapkan kategori tertentu dengan VBA


Pindahkan email ke folder tertentu setelah menetapkan kategori tertentu dengan VBA

Kode VBA di bawah ini dapat membantu memindahkan email secara otomatis ke folder tertentu setelah menetapkan kategori tertentu di Outlook. Silakan lakukan sebagai berikut.

1. tekan lain + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Dalam Microsoft Visual Basic untuk Aplikasi jendela, klik dua kali untuk membuka ThisOutlookSession (Kode) jendela. Kemudian salin kode VBA di bawah ini ke jendela. Lihat tangkapan layar:

Kode VBA: Pindahkan email ke folder tertentu setelah menetapkan kategori tertentu

Private WithEvents xInboxFld As Outlook.Folder
Private WithEvents xInboxItems As Outlook.Items

Private Sub Application_Startup()
    Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
    Set xInboxItems = xInboxFld.Items
End Sub

Private Sub xInboxItems_ItemChange(ByVal Item As Object)
Dim xMailItem As Outlook.MailItem
Dim xFlds As Outlook.Folders
Dim xFld As Outlook.Folder
Dim xTargetFld As Outlook.Folder
Dim xFlag As Boolean
On Error Resume Next
If Item.Class = olMail Then
    Set xMailItem = Item
    xFlag = False
    If xMailItem.Categories <> "" Then
        Set xFlds = Application.Session.GetDefaultFolder(olFolderInbox).Folders
        If xFlds.Count <> 0 Then
            For Each xFld In xFlds
                If xFld.Name = xMailItem.Categories Then
                    xFlag = True
                End If
            Next
        End If
        If xFlag = False Then
            Application.Session.GetDefaultFolder(olFolderInbox).Folders.Add xMailItem.Categories, olFolderInbox
        End If
        Set xTargetFld = Application.Session.GetDefaultFolder(olFolderInbox).Folders(xMailItem.Categories)
        xMailItem.Move xTargetFld
    End If
End If
End Sub

3. Simpan kode dan mulai ulang Outlook.

4. Mulai sekarang, ketika menetapkan kategori ke email penerima, folder dengan nama kategori akan dibuat secara otomatis di bawah folder Kotak Masuk dengan email yang dipindahkan. Lihat tangkapan layar:

Note: Semua email dengan kategori yang sama akan dipindahkan ke folder yang sama secara otomatis. Namun jika kategori baru ditetapkan ke email, folder baru akan dibuat secara otomatis.


Artikel terkait:

Alat Produktivitas Kantor Terbaik

馃 Kutools AI Ajudan: Merevolusi analisis data berdasarkan: Eksekusi Cerdas   |  Hasilkan Kode  |  Buat Rumus Khusus  |  Analisis Data dan Hasilkan Grafik  |  Aktifkan Fungsi Kutools...
Fitur Populer: Temukan, Sorot, atau Identifikasi Duplikat   |  Hapus Baris Kosong   |  Gabungkan Kolom atau Sel tanpa Kehilangan Data   |   Putaran tanpa Formula ...
Pencarian Super: VLookup Beberapa Kriteria    VLookup Nilai Berganda  |   VLookup di Beberapa Lembar   |   Pencarian Fuzzy ....
Daftar Drop-down Lanjutan: Buat Daftar Drop Down dengan Cepat   |  Daftar Drop Down yang Bergantung   |  Multi-pilih Drop Down List ....
Manajer Kolom: Tambahkan Jumlah Kolom Tertentu  |  Pindahkan Kolom  |  Alihkan Status Visibilitas Kolom Tersembunyi  |  Bandingkan Rentang & Kolom ...
Fitur Unggulan: Fokus Kisi   |  Tampilan Desain   |   Bar Formula Besar    Manajer Buku Kerja & Lembar   |  Perpustakaan Sumberdaya (Teks otomatis)   |  Pemetik tanggal   |  Gabungkan Lembar Kerja   |  Enkripsi/Dekripsi Sel    Kirim Email berdasarkan Daftar   |  Filter Super   |   Filter Khusus (filter tebal/miring/coret...) ...
15 Perangkat Teratas12 Teks Tools (Tambahkan Teks, Hapus Karakter, ...)   |   50 + Grafik jenis (Gantt Chart, ...)   |   40+ Praktis Rumus (Hitung usia berdasarkan ulang tahun, ...)   |   19 Insersi Tools (Masukkan Kode QR, Sisipkan Gambar dari Jalur, ...)   |   12 Konversi Tools (Angka ke Kata, Konversi Mata Uang, ...)   |   7 Gabungkan & Pisahkan Tools (Lanjutan Gabungkan Baris, Pisahkan Sel, ...)   |   ... dan banyak lagi

Tingkatkan Keterampilan Excel Anda dengan Kutools for Excel, dan Rasakan Efisiensi yang Belum Pernah Ada Sebelumnya. Kutools for Excel Menawarkan Lebih dari 300 Fitur Lanjutan untuk Meningkatkan Produktivitas dan Menghemat Waktu.  Klik Di Sini untuk Mendapatkan Fitur yang Paling Anda Butuhkan...

Deskripsi Produk


Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour
je cherchais cette fonction depuis un moment pour classer mes mails.
Malheureusement 莽a ne fonctionne pas. J'ai outlook 2019 au boulot peut-锚tre est-ce 脿 cause de 莽a ? ou alors vu que je ne maitrise pas Virtual Basis ai-je fait une b锚tise ?
Si quelqu'un peut m'(aider svp, je touche du doigt le graal mais il me manque de l'aide, svp....
Nico
This comment was minimized by the moderator on the site
I want to add more feature in this code. For instance, once email moved to business folder, I need this email to be automatically forward to specific email address. Possible?
This comment was minimized by the moderator on the site
it works as a charm but i want to take it to the next step. using a different folder instead of the inbox for example a folder called 2020 under the head and then from there the mentioned subfolders based on Categories. i was thinking to add this line.. Set xInboxFld = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).outlook.Application.Session.GetDefaultFolder(xMailItem.Categories)
This comment was minimized by the moderator on the site
worked on all mails not only after read. i created a rule mention a certain name that it gets a catergory. how can make it that it only takes the mails which are read?
This comment was minimized by the moderator on the site
This worked for me. would you be able to edit the code just to have the messages moved to one folder instead of creating one for each category. I have all the emails in one folder regardless of category and sort them in the folder.
This comment was minimized by the moderator on the site
At first this did not work for me either but after a while it just started to work, I'm not sure why though.
This comment was minimized by the moderator on the site
same here. Didn't work
This comment was minimized by the moderator on the site
Did not work.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations