メインコンテンツへスキップ

 連絡先の誕生日が今日Outlookにある場合、連絡先にグリーティングメッセージを自動的に送信するにはどうすればよいですか?

連絡先の誕生日が今日Outlookにあるときに、連絡先にグリーティングメッセージを自動的に送信したい場合があります。 連絡先の誕生日をXNUMXつずつ確認し、手動で挨拶メールを送信するのは面倒な作業になります。 この記事では、それをすばやく簡単に解決するためのVBAコードを紹介します。

OutlookのVBAコードを使用して、誕生日に基づいて連絡先にグリーティングメッセージを自動的に送信します


OutlookのVBAコードを使用して、誕生日に基づいて連絡先にグリーティングメッセージを自動的に送信します

連絡先の誕生日が今日の場合にグリーティングメッセージを連絡先に自動的に送信するには、最初にVBAコードを挿入してから、コードをトリガーする定期的なタスクを作成する必要があります。

次の手順が役立ちます。

1。 Outlookを起動し、 Alt + F11 キーを押して アプリケーション向け Microsoft Visual Basic 窓。

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウ、ダブルクリック このOutlookSession Project1(VbaProject.OTM) ペインでモードを開き、次のコードをコピーして空のモジュールに貼り付けます。

VBAコード:誕生日に基づいて連絡先にグリーティングメッセージを自動送信します。

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。 次にクリックします ツール > 参考文献 セクションに アプリケーション向け Microsoft Visual Basic 飛び出した窓 参考資料-Project1 ダイアログボックス、チェック MicrosoftWordオブジェクトライブラリ & Microsoftスクリプトランタイム からのオプション 利用可能な参考文献 リストボックス、スクリーンショットを参照:

4。 次に、をクリックします OK ダイアログを閉じるには、VBA コードをトリガーするタスクを作成する必要があります。 に行ってください。 仕事 ペインをクリック 新しいタスク タスクを作成するには:

(1.)で サブジェックt 行目では、件名を次のように入力する必要があります。 誕生日のお祝いメールを送信する;

(2.)次にクリックします 再発仕事 タブ;

(3.) タスクの繰り返し ダイアログボックスで 毎日 と指定します 1日ごと オプションから 再発パターン セクション;

5。 次に、をクリックします OK ダイアログ ボックスを閉じてタスク ウィンドウに戻り、次のスクリーンショットに示すように、定期的なタスクのリマインダーを設定してください。

6。 今後は、リマインダーが警告すると、マクロがすぐにトリガーされます。 次のスクリーンショットに示すように、誕生日の挨拶を挿入することを促すダイアログ ボックスが表示されます。

7。 次に、をクリックします OK ボタンを押すと、今日が誕生日の連絡先に自動で挨拶メールが送信されます。


最高のオフィス生産性向上ツール

Kutools for Outlook - Outlook を強化する 100 以上の強力な機能

🤖 AIメールアシスタント: AI の魔法を備えたインスタント プロのメール - ワンクリックで天才的な返信、完璧な口調、多言語の習得。メールを簡単に変革しましょう! ...

📧 自動メール: 不在時 (POP および IMAP で利用可能)  /  メール送信のスケジュール設定  /  メール送信時のルールによる自動CC/BCC  /  自動転送 (高度なルール)   /  あいさつを自動追加   /  複数受信者の電子メールを個別のメッセージに自動的に分割する ...

📨 電子メール管理: メールを簡単に思い出す  /  件名などで詐欺メールをブロック  /  重複するメールを削除する  /  高度な検索  /  フォルダーを統合する ...

📁 アタッチメント プロバッチ保存  /  バッチデタッチ  /  バッチ圧縮  /  自動保存   /  自動デタッチ  /  自動圧縮 ...

🌟 インターフェースマジック: 😊もっと可愛くてクールな絵文字   /  タブ付きビューで Outlook の生産性を向上  /  Outlook を閉じる代わりに最小化する ...

???? ワンクリックの驚異: 受信した添付ファイルをすべてに返信する  /   フィッシングメール対策  /  🕘送信者のタイムゾーンを表示 ...

👩🏼‍🤝‍👩🏻 連絡先とカレンダー: 選択したメールから連絡先を一括追加  /  連絡先グループを個別のグループに分割する  /  誕生日のリマインダーを削除する ...

オーバー 100の特長 あなたの探索をお待ちしています! ここをクリックして詳細をご覧ください。

 

 

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