如何在 Outlook 中快速將收件人姓名插入電子郵件正文

立即分享:

如果您想在撰寫電子郵件時快速將收件人姓名插入正文,可以閱讀本文。 下面我們就給大家介紹一個方便的方法。

有時,您在撰寫電子郵件時可能需要在正文中輸入所有收件人的姓名。 無疑,手動將名字一一提取並插入到body中是相當繁瑣和麻煩的。 因此,為了幫助您快速完成此任務,這裡我們向您分享一個有效的方法。 繼續閱讀以了解其詳細步驟。

將收件人姓名插入電子郵件正文

  1. 對於作為tart,通過“ Alt + F11”訪問VBA編輯器。
  2. 然後,在“Microsoft Visual Basic for Applications”窗口中,啟用“MS Word Object Library”,根據“如何添加對像庫rary VBA中的參考“。
  3. 接下來,將下面的VBA代碼複製到一個空模塊中。
Sub CopyRecipientNamesToBody()
    Dim objMail As Outlook.MailItem
    Dim objRecipient As Outlook.Recipient
    Dim strRecipAddress As String
    Dim strRecipName As String
    Dim objContacts As Outlook.Items
    Dim i As Integer
    Dim strFilter As String
    Dim objFoundContact As Outlook.ContactItem
    Dim strRecipNames As String
    Dim objMailDocument As Word.Document
 
    'Get the current email
    Set objMail = Application.ActiveInspector.CurrentItem
    objMail.Recipients.ResolveAll
 
    For Each objRecipient In objMail.Recipients
        strRecipAddress = objRecipient.Address
 
        'Get the corresponding contact name
        Set objContacts = Application.Session.GetDefaultFolder(olFolderContacts).Items
        For i = 1 To 3
            strFilter = "[Email" & i & "Address] = " & strRecipAddress
            Set objFoundContact = objContacts.Find(strFilter)
            If Not (objFoundContact Is Nothing) Then
               strRecipNames = strRecipNames & objFoundContact.FullName & vbCr
               Exit For
            End If
        Next
 
        'If there isn't associated contact
        'Extract name from email address
        If objFoundContact Is Nothing Then
           strRecipName = Split(strRecipAddress, "@")(0)
           strRecipName = UCase(Left(strRecipName, 1)) & Right(strRecipName, Len(strRecipName) - 1)
           strRecipNames = strRecipNames & strRecipName & vbCr
        End If
    Next
 
    'Insert the names at the beginning of email
    Set objMailDocument = objMail.GetInspector.WordEditor
    objMailDocument.Range(0, 0).InsertAfter strRecipNames
End Sub

VBA 代碼 - 將收件人姓名插入電子郵件正文

  1. 接下來,根據“中的可選步驟”將此宏添加到消息窗口的快速訪問工具欄如何在Outlook中運行VBA代碼“。
  2. 之後,退出窗口。
  3. 最後,來一槍。
  • 首先,撰寫電子郵件並填寫收件人。
  • 然後,點擊快速訪問工具欄中的宏按鈕。單擊宏按鈕
  • 宏完成後,收件人姓名已插入到電子郵件正文中,如下圖所示。在電子郵件正文中插入收件人姓名

防止外觀損壞

由於 Outlook 容易受到攻擊,因此很難保護 Outlook 免受損壞。 毫無疑問,你一定不願意遇見 PST腐敗。 因此,您最好採取一些有效的預防措施。 例如,您需要對 Outlook 進行一致的數據備份,熟悉如何使用收件箱修復工具以及在附近保留強大的外部工具,例如 DataNumen Outlook Repair.

作者簡介:

Shirley Zhang是的數據恢復專家 DataNumen,Inc.是數據恢復技術的全球領導者,包括 SQL Server 固定 和Outlook修復軟件產品。 欲了解更多信息,請訪問 萬維網。datanumen.COM

立即分享:

評論被關閉。