從 Outlook 的收件人選取功能中移除傳真號碼

使用 Outlook 的時候,若是有在連絡人建立完整的連絡人資訊(包含傳真號碼)時,當要寄郵件選取收件人的時候每個聯絡人會出現兩筆資料,一筆是 email 一筆是 Fax,因為沒有用電腦發傳真的需要,出現傳真號碼實在會覺得礙眼,因此找了一下解決方法,並稍微增加功能。

參考自:http://www.davidfisco.com/node/90

Sub ChangeContactFax_AddTag()
 Set olApp = New Outlook.Application
 Set olNS = olApp.GetNamespace("MAPI")
 Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts)
 Set ContactItems = ContactsFolder.Items
 For Each Itm In ContactItems
 If Itm.MessageClass = "IPM.Contact" Then
 If Itm.BusinessFaxNumber <> "" And (InStr(1, Itm.BusinessFaxNumber, "FAX:") <> 1) Then
 tempString = "FAX: " & Itm.BusinessFaxNumber
 Debug.Print Itm.BusinessFaxNumber
 Itm.BusinessFaxNumber = tempString
 Itm.Save
 End If
 End If
 Next
End Sub

Sub ChangeContactFax_RemoveTag()
 Set olApp = New Outlook.Application
 Set olNS = olApp.GetNamespace("MAPI")
 Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts)
 Set ContactItems = ContactsFolder.Items
 For Each Itm In ContactItems
 If Itm.MessageClass = "IPM.Contact" Then
 If Itm.BusinessFaxNumber <> "" And (InStr(1, Itm.BusinessFaxNumber, "FAX:") = 1) Then
 tempString = Replace(Itm.BusinessFaxNumber, "FAX: ", "")
 Debug.Print tempString
 Itm.BusinessFaxNumber = tempString
 Itm.Save
 End If
 End If
 Next
End Sub

如果要處理聯絡人的子項目類別的話,要改:

Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts).Folders("子資料夾名稱")
分類: 資訊技術相關雜記,標籤: 。這篇內容的永久連結