Прескочи на основното съдържание

Как да създадете автоматично име на скъп подател, когато отговаряте на съобщение в Outlook?

Автор: Xiaoyang Последна промяна: 2020-08-07

Когато отговаряте на имейл съобщение, трябва да въведете ръчно името на подателя и поздравите. За да спестите време и да подобрите ефективността на работата, може да помислите за автоматично създаване на име и поздрави на скъп подател в Outlook. В тази статия ще говоря за някои полезни методи за решаване на тази задача в Outlook.

Създайте автоматично име и поздрави на скъп подател, когато отговаряте на съобщение с VBA код

Създайте автоматично име и поздрави на скъп подател, когато отговаряте на съобщение с Kutools за Outlook


Създайте автоматично име и поздрави на скъп подател, когато отговаряте на съобщение с VBA код

Следният VBA код може да ви помогне да вмъкнете автоматично името и поздравите на скъп подател, когато отговаряте на имейл съобщение, моля, направете следното:

1. Задръжте натиснат ALT + F11 за да отворите Microsoft Visual Basic за приложения прозорец.

2. В Microsoft Visual Basic за приложения прозорец, щракнете два пъти ThisOutlookSession от Проект1(VbaProject.OTM) прозорец, за да отворите режима, и след това копирайте и поставете следния код в празния модул.

VBA код: Автоматично вмъкване на име и поздрави на скъп подател, когато отговаряте:

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 скъпи име на изпращача 1

3. След това затворете Outlook и го рестартирайте, за да приемете ефекта на кода, и сега, когато отговорите на имейл съобщение, името и поздравите на скъп подател се вмъкват автоматично в тялото, вижте екранната снимка:

doc auto скъпи име на изпращача 2


Създайте автоматично име и поздрави на скъп подател, когато отговаряте на съобщение с Kutools за Outlook

Ако имате Kutools за Outlook, Със своята Добавете поздрав при отговор Outlook автоматично ще вмъкне името на подателя, когато отговаря.

Kutools за Outlook : с повече от 100 удобни добавки за Outlook, безплатни за изпробване без ограничение за 60 дни. 

След инсталиране Kutools за Outlook, моля, направете следното:

1. Щракнете Kutools > Настроики, вижте екранна снимка:

doc auto скъпи име на изпращача 3

2. В Настроики диалогов прозорец, под Отговор таб, проверете Добавете поздрав при отговор опция и след това въведете поздравите, както ви е необходимо, вижте екранната снимка:

doc auto скъпи име на изпращача 4

3, След това кликнете OK за да завършите тази настройка, от сега нататък, когато отговаряте на съобщение, поздравите ще се създават автоматично пред тялото на съобщението, вижте екранната снимка:

doc auto скъпи име на изпращача 5

Щракнете, за да изтеглите Kutools за Outlook и безплатна пробна версия сега!


Най-добрите инструменти за продуктивност в офиса

Kutools за Outlook - Над 100 мощни функции, за да заредите вашия Outlook

🤖 AI Mail Assistant: Незабавни професионални имейли с AI магия - с едно щракване до гениални отговори, перфектен тон, многоезично владеене. Трансформирайте имейла без усилие! ...

📧 Автоматизиране на имейли: Извън офиса (налично за POP и IMAP)  /  График за изпращане на имейли  /  Автоматично CC/BCC по правила при изпращане на имейл  /  Автоматично пренасочване (разширени правила)   /  Автоматично добавяне на поздрав   /  Автоматично разделяне на имейлите с множество получатели на отделни съобщения ...

📨 Управление на Email: Лесно извикване на имейли  /  Блокиране на измамни имейли по теми и други  /  Изтриване на дублирани имейли  /  подробно търсене  /  Консолидиране на папки ...

📁 Прикачени файлове ProПакетно запазване  /  Партидно отделяне  /  Партиден компрес  /  Автоматично запазване   /  Автоматично отделяне  /  Автоматично компресиране ...

🌟 Магия на интерфейса: 😊 Още красиви и готини емотикони   /  Увеличете продуктивността на Outlook с изгледи с раздели  /  Минимизирайте Outlook, вместо да затваряте ...

???? Чудеса с едно кликване: Отговорете на всички с входящи прикачени файлове  /   Антифишинг имейли  /  🕘Показване на часовата зона на подателя ...

👩🏼‍🤝‍👩🏻 Контакти и календар: Групово добавяне на контакти от избрани имейли  /  Разделете група контакти на отделни групи  /  Премахнете напомнянията за рожден ден ...

Над 100 Характеристики Очаквайте вашето проучване! Щракнете тук, за да откриете повече.

 

 

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