Przejdź do głównej zawartości

Jak automatycznie utworzyć imię drogiego nadawcy podczas odpowiadania na wiadomość w Outlooku?

Odpowiadając na wiadomość e-mail, należy ręcznie wpisać nazwę nadawcy i pozdrowienia. Aby zaoszczędzić czas i poprawić wydajność pracy, możesz rozważyć automatyczne utworzenie imienia i nazwiska drogiego nadawcy oraz pozdrowienia w programie Outlook. W tym artykule omówię kilka przydatnych metod rozwiązania tego zadania w Outlooku.

Automatycznie utwórz imię i pozdrowienia drogiego nadawcy podczas odpowiadania na wiadomość z kodem VBA

Automatycznie utwórz imię i pozdrowienia drogiego nadawcy podczas odpowiadania na wiadomość za pomocą Kutools for Outlook


Automatycznie utwórz imię i pozdrowienia drogiego nadawcy podczas odpowiadania na wiadomość z kodem VBA

Poniższy kod VBA może pomóc w automatycznym wstawieniu imienia i nazwiska drogiego nadawcy i pozdrowień podczas odpowiadania na wiadomość e-mail, wykonaj następujące czynności:

1. Przytrzymaj ALT + F11 klawisze, aby otworzyć Microsoft Visual Basic for Applications okno.

2, w Microsoft Visual Basic for Applications kliknij dwukrotnie Ta sesja programu Outlook z Project1 (VbaProject.OTM) okienko, aby otworzyć tryb, a następnie skopiuj i wklej następujący kod do pustego modułu.

Kod VBA: Automatycznie wstaw imię i pozdrowienia drogiego nadawcy podczas odpowiadania:

Public WithEvents GExplorer As Outlook.Explorer
Public WithEvents GMailItem As Outlook.MailItem
Private Sub Application_Startup()
    Set GExplorer = Outlook.Application.ActiveExplorer
End Sub
Private Sub GExplorer_SelectionChange()
    Dim xItem As Object
    On Error Resume Next
    Set xItem = GExplorer.Selection.Item(1)
    If xItem.Class <> olMail Then Exit Sub
    Set GMailItem = xItem
End Sub
Private Sub GMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
    AutoAddGreetingToReply Response
End Sub
Private Sub GMailItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    AutoAddGreetingToReply Response
End Sub
Sub AutoAddGreetingToReply(Item As Object)
    Dim xGreetStr As String
    Dim xReplyMail As MailItem
    Dim xSenderName As String
    Dim xRecipient As Recipient
    On Error Resume Next
    If Item.Class <> olMail Then Exit Sub
    Set xReplyMail = Item
    For Each xRecipient In xReplyMail.Recipients
        If xSenderName = "" Then
            xSenderName = xRecipient.Name
        Else
            xSenderName = xSenderName & "," & xRecipient.Name
        End If
    Next xRecipient
    Select Case Time
           Case 0.3 To 0.5
                xGreetStr = " Good morning!"
           Case 0.5 To 0.75
                xGreetStr = " Good afternoon!"
           Case Else
                xGreetStr = " Good evening!"
    End Select
    With xReplyMail
        .Display
        .HTMLBody = "<HTML><Body>Dear " & xSenderName & ",</HTML></Body>" & xGreetStr & .HTMLBody
    End With
End Sub

doc auto droga nazwa nadawcy 1

3. Następnie zamknij Outlooka i uruchom go ponownie, aby uzyskać efekt kodu, a teraz, gdy odpowiadasz na wiadomość e-mail, imię i pozdrowienia drogiego nadawcy są automatycznie wstawiane do treści, patrz zrzut ekranu:

doc auto droga nazwa nadawcy 2


Automatycznie utwórz imię i pozdrowienia drogiego nadawcy podczas odpowiadania na wiadomość za pomocą Kutools for Outlook

Jeśli Kutools dla programu Outlook, Z siedzibą w Dodaj powitanie do odpowiedzi funkcja Outlook automatycznie wstawi nazwę nadawcy podczas odpowiadania.

Kutools dla programu Outlook : z ponad 100 przydatnymi dodatkami do Outlooka, które można wypróbować bezpłatnie przez 60 dni bez ograniczeń. 

Po zainstalowaniu Kutools dla programu Outlook, zrób tak :

1. Kliknij Kutools > Opcjezobacz zrzut ekranu:

doc auto droga nazwa nadawcy 3

2, w Opcje okno dialogowe w obszarze Odpowiedz zakładka, sprawdź Dodaj powitanie do odpowiedzi opcja, a następnie wprowadź pozdrowienia, jak potrzebujesz, patrz zrzut ekranu:

doc auto droga nazwa nadawcy 4

3. Następnie kliknij OK aby zakończyć to ustawienie, od teraz podczas odpowiadania na wiadomość pozdrowienia będą tworzone automatycznie przed treścią wiadomości, patrz zrzut ekranu:

doc auto droga nazwa nadawcy 5

Kliknij, aby pobrać Kutools dla programu Outlook i bezpłatną wersję próbną już teraz!


Najlepsze narzędzia biurowe

Kutools dla programu Outlook - Ponad 100 zaawansowanych funkcji, które usprawnią Twoje perspektywy

🤖 Asystent poczty AI: Natychmiastowe profesjonalne e-maile z magią AI — genialne odpowiedzi jednym kliknięciem, doskonały ton, biegła znajomość wielu języków. Zmień e-mailing bez wysiłku! ...

📧 Automatyzacja poczty e-mail: Poza biurem (dostępne dla POP i IMAP)  /  Zaplanuj wysyłanie wiadomości e-mail  /  Automatyczne CC/BCC według reguł podczas wysyłania wiadomości e-mail  /  Automatyczne przewijanie (Zasady zaawansowane)   /  Automatyczne dodawanie powitania   /  Automatycznie dziel wiadomości e-mail od wielu odbiorców na pojedyncze wiadomości ...

📨 Zarządzanie e-mail: Łatwe przywoływanie e-maili  /  Blokuj oszukańcze wiadomości e-mail według tematów i innych  /  Usuń zduplikowane wiadomości e-mail  /  Wiecej opcji  /  Konsoliduj foldery ...

📁 Załączniki ProZapisz zbiorczo  /  Odłącz partię  /  Kompresuj wsadowo  /  Automatyczne zapisywanie   /  Automatyczne odłączanie  /  Automatyczna kompresja ...

🌟 Magia interfejsu: 😊Więcej ładnych i fajnych emotikonów   /  Zwiększ produktywność programu Outlook dzięki widokom na kartach  /  Zminimalizuj program Outlook zamiast go zamykać ...

>> Cuda jednym kliknięciem: Odpowiedz wszystkim, dodając przychodzące załączniki  /   E-maile chroniące przed phishingiem  /  🕘Pokaż strefę czasową nadawcy ...

👩🏼‍🤝‍👩🏻 Kontakty i kalendarz: Grupowe dodawanie kontaktów z wybranych e-maili  /  Podziel grupę kontaktów na pojedyncze grupy  /  Usuń przypomnienia o urodzinach ...

O Cechy 100 Poczekaj na eksplorację! Kliknij tutaj, aby dowiedzieć się więcej.

 

 

Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi skyyang,

I need the macro to insert only the first name of the person I receive the email from. Not all the names from CC, but not to remove anyone. Also, to maintain my default color scale (R: 31, G: 73, B: 125) and font size (11 pt) with an additional line after the sender name. Please help me with this. Thanks in advance
This comment was minimized by the moderator on the site
Bonjour,
Puis je avoir le code VBA pour insérer "Bonjour prénom," seulement ???

Merci de votre aide.
This comment was minimized by the moderator on the site
Hello, Nicolas
Please apply the below code:
Public WithEvents GExplorer As Outlook.Explorer
Public WithEvents GMailItem As Outlook.MailItem
Private Sub Application_Startup()
    Set GExplorer = Outlook.Application.ActiveExplorer
End Sub
Private Sub GExplorer_SelectionChange()
    Dim xItem As Object
    On Error Resume Next
    Set xItem = GExplorer.Selection.Item(1)
    If xItem.Class <> olMail Then Exit Sub
    Set GMailItem = xItem
End Sub
Private Sub GMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
    AutoAddGreetingToReply Response
End Sub
Private Sub GMailItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    AutoAddGreetingToReply Response
End Sub
Sub AutoAddGreetingToReply(Item As Object)
    Dim xReplyMail As MailItem
    Dim xSenderName As String
    Dim xRecipient As Recipient
    On Error Resume Next
    If Item.Class <> olMail Then Exit Sub
    Set xReplyMail = Item
    For Each xRecipient In xReplyMail.Recipients
        If xSenderName = "" Then
            xSenderName = xRecipient.Name
        Else
            xSenderName = xSenderName & "," & xRecipient.Name
        End If
    Next xRecipient
    With xReplyMail
        .Display
        .HTMLBody = "<HTML><Body>Dear " & xSenderName & ",</HTML></Body>" & .HTMLBody
    End With
End Sub

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hi.
What do i need to edit in the VBA code to include first name only and to omit the "(s)" after Dear?
Thanks
This comment was minimized by the moderator on the site
Hello, Matt,
To solve your problem, the follwoing VBA code may do you a favor:
Public WithEvents GExplorer As Outlook.Explorer
Public WithEvents GMailItem As Outlook.MailItem
Private Sub Application_Startup()
  Set GExplorer = Outlook.Application.ActiveExplorer
End Sub
Private Sub GExplorer_SelectionChange()
  Dim xItem As Object
  On Error Resume Next
  Set xItem = GExplorer.Selection.Item(1)
  If xItem.Class <> olMail Then Exit Sub
  Set GMailItem = xItem
End Sub
Private Sub GMailItem_Reply(ByVal Response As Object, Cancel As Boolean)
  AutoAddGreetingToReply Response
End Sub
Private Sub GMailItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
  AutoAddGreetingToReply Response
End Sub
Sub AutoAddGreetingToReply(Item As Object)
  Dim xGreetStr As String
  Dim xReplyMail As MailItem
  Dim xSenderName As String
  Dim xRcpName As String
  Dim xRecipient As Recipient
  Dim xContactItem As ContactItem
  Dim xExUser As ExchangeUser
  On Error Resume Next
  If Item.Class <> olMail Then Exit Sub
  Set xReplyMail = Item
  xSenderName = ""
  xRcpName = ""
  For Each xRecipient In xReplyMail.Recipients
    Set xExUser = Nothing
    Set xContactItem = Nothing
    If xRecipient.AddressEntry.AddressEntryUserType < 6 Then
      Set xExUser = xRecipient.AddressEntry.GetExchangeUser
    Else
      Set xContactItem = xRecipient.AddressEntry.GetContact
    End If
    If Not xExUser Is Nothing Then
      If xSenderName = "" Then
        xSenderName = xExUser.FirstName
        If xSenderName = "" Then
          xSenderName = xRecipient.Name
        End If
      Else
        xSenderName = xSenderName & ", " & xExUser.FirstName
        If xExUser.FirstName = "" Then
          xSenderName = xSenderName & xRecipient.Name
        End If
      End If
    ElseIf Not xContactItem Is Nothing Then
      If xSenderName = "" Then
        xSenderName = xContactItem.FirstName
        If xSenderName = "" Then
          xSenderName = xRecipient.Name
        End If
      Else
        xSenderName = xSenderName & ", " & xContactItem.FirstName
        If xRecipient.FirstName = "" Then
          xSenderName = xSenderName & xRecipient.Name
        End If
      End If
    Else
      If xSenderName = "" Then
        xSenderName = xRecipient.Name
      Else
        xSenderName = xSenderName & ", " & xRecipient.Name
      End If
    End If
  Next xRecipient
  Select Case Time
    Case 0.3 To 0.5
      xGreetStr = " Good morning!"
    Case 0.5 To 0.75
      xGreetStr = " Good afternoon!"
    Case Else
      xGreetStr = " Good evening!"
  End Select
  With xReplyMail
    .Display
    .HTMLBody = "<HTML><Body>Dear " & xSenderName & ",</HTML></Body>" & xGreetStr & .HTMLBody
  End With
End Sub

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hello
Thank you for the suggestions, although it does not work. I wish to include the first name only and to omit the "(s)" after Dear?
This comment was minimized by the moderator on the site
Hello, Matt,
The above code works well.
First, you must make sure the recipient address has been added into the Contact folder in your Outlook.
If the recipient isn't in the Contact folder, when you applying this code, the full nae will be displayed.
Thank you!
This comment was minimized by the moderator on the site
Hello

Thank you for your reply! I will add contacts to my folder. I was wondering if there is a way to always display the first name only, even without contacts within my folder. For context, I work at a large university, and would be difficult and time-consuming to find all staff members individually.
This comment was minimized by the moderator on the site
Hello, Matt,

Sorry, if you haven't added the contact to the contact folder, the code will not get the recipient's first name.
Thank you!
This comment was minimized by the moderator on the site
Hi.
What do i need to edit in the VBA code to include first name only and to omit the "(s)" after Dear?
Thanks
This comment was minimized by the moderator on the site
Dear Team,

If I have set up the above configuration however, if I am replying to an email that has multiply recipients in the To, the greeting is not defaulting. How do I achieve this?
This comment was minimized by the moderator on the site
Hello, Wesley,
Yes, as you said, if there are multiple recipients in the To field, the greeting will not be inserted by default.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations