[英]Create User Defined Contact Field in Outlook using VBA
我正在嘗試編寫一個Outlook宏,它將在所有聯系人上創建一個新字段,然后根據另一個現有字段填充該字段。 到目前為止,這就是我所擁有的。 它似乎並沒有創造任何東西。
Sub ChangeField()
Dim ContactsFolder As Folder
Dim Contact As ContactItem
Dim objProperty As UserDefinedProperty
Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)
MsgBox ("Contacts Found: " & ContactsFolder.Items.Count)
With ContactsFolder.UserDefinedProperties
Set objProperty = .Add("CustomCompanyField", olText)
End With
For Each Contact In ContactsFolder.Items
Contact.CustomCompanyField = Contact.CompanyName
Contact.Save
Next
End Sub
可以通過VBA完成嗎? 還是只能手動創建聯系人字段? 任何幫助表示贊賞!
嘗試更換線
Contact.CustomCompanyField = Contact.CompanyName
與
Contact.UserProperties.Add("CustomCompanyField", olText).Value = Contact.CompanyName
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.