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

 كيف ترسل رسالة ترحيب إلى جهة اتصال تلقائيًا إذا كان عيد ميلاده اليوم في Outlook؟

في وقت ما ، قد ترغب في إرسال رسالة ترحيب تلقائيًا إلى جهة الاتصال عندما يكون عيد ميلاده اليوم في Outlook. ستكون مهمة شاقة عندما تتحقق من عيد ميلاد جهة الاتصال واحدة تلو الأخرى وترسل رسائل البريد الإلكتروني الترحيبية يدويًا. في هذه المقالة ، سأقدم رمز VBA لحلها بسرعة وسهولة.

أرسل رسالة ترحيب تلقائيًا إلى جهة اتصال بناءً على عيد ميلاده باستخدام رمز VBA في Outlook

أرسل رسالة ترحيب تلقائيًا إلى جهة اتصال بناءً على عيد ميلاده باستخدام رمز VBA في Outlook

لإرسال رسالة ترحيب تلقائيًا إلى جهة اتصال إذا كان عيد ميلاده اليوم ، أدخل رمز VBA أولاً ، ثم تحتاج إلى إنشاء مهمة متكررة لتشغيل الرمز.

قد تساعدك الخطوات التالية:

1. قم بتشغيل Outlook ، ثم اضغط باستمرار على ملف ALT + F11 مفاتيح لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. في ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، انقر مرتين هذه الجلسة من مشروع 1 (VbaProject.OTM) لفتح الوضع ، ثم انسخ الكود التالي والصقه في الوحدة النمطية الفارغة.

رمز فبا: إرسال تلقائي لرسالة ترحيب إلى جهة اتصال بناءً على تاريخ الميلاد:

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!"
                .Close (olSave)
          End With
       End If
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
    IsFileExists = False
End If
End Function 

3. Then clcik Tools > References in the Microsoft Visual Basic for Applications window, in the popped out References-Project1 dialog box, check Microsoft Word Object Library and Microsoft Scripting Runtime options from the Available References list box, see screenshot:

4. Then click OK to close the dialog, now, you should create a task to trigger the VBA code. Please go to the Task pane, click New Task to create a task:

(1.) In Subject line, you should enter Subject as Send Birthday Greeting Mail;

(2.) Then click Recurrence under the Task tab;

(3.) In the Task Recurrence dialog box, select Daily and specify every 1 day(s) option from the Recurrence pattern section;

5. Then click OK to close the dialog box, return to the task window, please set a reminder for the recurring task as following screenshot shown:

6. From now on, when the reminder alerts, the macro will be triggered immediately. A dialog box will pop out to remind you inserting the birthday greetings as following screenshot shown:

7. Then click OK button, a greeting mail will be sent to the contact whose birthday is today automatically.

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 (5)
No ratings yet. Be the first to rate!
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
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
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
how he come to know who's birthday is not mention, from where he pick detail of the more thing, i want to send birthday mail to all employee email id.
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?
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations

Follow Us

Copyright © 2009 - | 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