Loncat ke daftar isi utama

 Bagaimana cara mengirim pesan ucapan ke kontak secara otomatis jika ulang tahunnya hari ini di Outlook?

Terkadang, Anda mungkin ingin mengirim pesan ucapan secara otomatis ke kontak saat ulang tahunnya hari ini di Outlook. Ini akan menjadi pekerjaan yang membosankan ketika Anda memeriksa ulang tahun kontak satu per satu dan mengirim email salam secara manual. Artikel ini, saya akan memperkenalkan kode VBA untuk menyelesaikannya dengan cepat dan mudah.

Kirim pesan ucapan secara otomatis ke kontak berdasarkan hari ulang tahunnya dengan kode VBA di Outlook


Kirim pesan ucapan secara otomatis ke kontak berdasarkan hari ulang tahunnya dengan kode VBA di Outlook

Untuk mengirim pesan ucapan secara otomatis ke kontak jika ulang tahunnya hari ini, masukkan kode VBA terlebih dahulu, lalu Anda perlu membuat tugas berulang untuk memicu kode.

Langkah-langkah berikut dapat membantu Anda:

1. Luncurkan Outlook, lalu tahan file ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. 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: Kirim pesan ucapan secara otomatis ke kontak berdasarkan tanggal lahir:

Private Sub Application_Reminder(ByVal Item As Object)
Dim xTempMail As MailItem
Dim xFilePath As String
Dim xItems As Outlook.Items
Dim xItem As Object
Dim xContactItem As Outlook.ContactItem
Dim xTodayDate As String
Dim xBirthdayDate As String
Dim xGreetingMail As Outlook.MailItem
Dim xWordDoc As Word.Document
Dim xGreetings As String
Dim xBool As Boolean
xFilePath = CreateObject("shell.Application").NameSpace(5).self.Path & "\UserTemplates"
Set xFSO = CreateObject("Scripting.FileSystemObject")
If xFSO.FolderExists(xFilePath) = False Then
    MkDir xFilePath
End If
If IsFileExists(xFilePath & "\Birthday Greeting Mail.oft") = False Then
    Set xTempMail = Outlook.CreateItem(olMailItem)
    xTempMail.SaveAs xFilePath & "\Birthday Greeting Mail.oft", olTemplate
    xTempMail.Close olDiscard
End If
If (TypeOf Item Is TaskItem) And (Item.Subject = "Send Birthday Greeting Mail") Then
xGreetings = "Happy Birthday!"
           xGreetings = InputBox("Input birthday greetings", "Kutools for Outlook", xGreetings)
   xTodayDate = Month(Date) & "-" & Day(Date)
   Set xItems = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items
   For Each xItem In xItems
       If Not (TypeOf xItem Is ContactItem) Then Exit Sub
       Set xContactItem = xItem
       xBirthdayDate = Month(xContactItem.Birthday) & "-" & Day(xContactItem.Birthday)
       If xBirthdayDate = xTodayDate Then
           Set xGreetingMail = Outlook.Application.CreateItemFromTemplate(xFilePath & "\Birthday Greeting Mail.oft")
           Set xWordDoc = xGreetingMail.GetInspector.WordEditor
           
           xWordDoc.Range.InsertBefore "Dear " & xContactItem.LastName & Chr(10) & xGreetings & Chr(10) & Chr(10)
           With xGreetingMail
                .Recipients.Add (xContactItem.Email1Address)
                .Subject = "Happy Birthday!"
                .Display
                .Close (olSave)
                .Send
          End With
       End If
   Next
End If
End Sub
Function IsFileExists(ByVal FileName As String) As Boolean
Dim xFileSystem As Object
Set xFileSystem = CreateObject("Scripting.FileSystemObject")
If xFileSystem.FileExists(FileName) = True Then
    IsFileExists = True
Else
    IsFileExists = False
End If
End Function 

3. Lalu klik Tools > Referensi dalam Microsoft Visual Basic untuk Aplikasi jendela, di muncul keluar Referensi-Proyek 1 kotak dialog, periksa Perpustakaan objek Microsoft Word dan Runtime Microsoft Scripting opsi dari Referensi yang Tersedia kotak daftar, lihat tangkapan layar:

4. Lalu klik OK untuk menutup dialog, sekarang, Anda harus membuat tugas untuk memicu kode VBA. Silakan pergi ke tugas pane, klik Tugas baru untuk membuat tugas:

(1.) Masuk mata pelajaranbaris t, Anda harus memasukkan Subjek sebagai Kirim Surat Ucapan Ulang Tahun;

(2.) Kemudian klik Kambuh bawah tugas Tab;

(3.) Di Perulangan Tugas kotak dialog, pilih Setiap hari dan tentukan setiap 1 hari pilihan dari Pola pengulangan bagian;

5. Lalu klik OK untuk menutup kotak dialog, kembali ke jendela tugas, harap atur pengingat untuk tugas berulang seperti gambar berikut yang ditampilkan:

6. Mulai sekarang, saat pengingat memberi peringatan, makro akan segera terpicu. Kotak dialog akan muncul untuk mengingatkan Anda memasukkan ucapan selamat ulang tahun seperti gambar berikut yang ditampilkan:

7. Lalu klik OK tombol, surat ucapan akan dikirim ke kontak yang berulang tahun hari ini secara otomatis.


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 (5)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Good morning,
I've set this up exactly as outlined, I have Kutools installed, however, there's no Macro popup when the reminder activates. What information can I provide you to help me solve this?
This comment was minimized by the moderator on the site
how he come to know who's birthday is today.you not mention, from where he pick detail of the employee.one more thing, i want to send birthday mail to all employee email id.
This comment was minimized by the moderator on the site
I am using this code with outlook 2016. Followed all the steps but kutool popup is not coming as mentioned in last step
This comment was minimized by the moderator on the site
hay alguna forma para mac?
This comment was minimized by the moderator on the site
Buen día, podría indicar cómo el código obtiene y valida la fecha de nacimiento??? . Otra consulta es si funciona para una lista de usuarios. Es decir que valide sus fechas de nacimiento y les envíe automáticamente saludos de cumpleaños. Muchas gracias
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations