I've added a Yes/No field to Outlook called "imported" with the purpose of being able to check off emails once they are imported into a d/base. While I can create the UDF for various Outlook folders and subfolders, see the field in these folders and manually check and uncheck the boxes, I cannot programmatically check or uncheck boxes for Mail Items unless I have manually used the checkbox for the Outlook item. This is obviously unworkable. Assigning a starting value when the UDF was created does not work, and I cannot change values for individual Mail Items after creating the UDF unless I first manually use the field. Any help is greatly appreciated.
The coding (generally) used to create the UDF was:
Sub AddFolders(CurrentFolder As Outlook.Folder, TabChars, ByRef Report As String)
Dim SubFolder As Outlook.Folder
Dim objFolder As Object
Dim myUserProperty As Outlook.UserDefinedProperty
Dim objMailItem As Object
Dim intItemsCount As Integer
Dim strAddImported As String
strAddImported = "Imported"
For Each SubFolder In CurrentFolder.Folders
Set objFolder = SubFolder
Set myUserProperty = SubFolder.UserDefinedProperties.Add("Imported", olYesNo, True)
myUserPropery.UserProperties.Value = False
Attempts to change UDF values generally look as follows (it works for Mail Items I have manually used the UDF, but will not work for those I have not manually used):
For Each objMailItem In objFolder.Items
objMailItem.UserProperties(strAddImported).Value = False
objMailItem.Save
objMailItem.UserProperties(strAddImported).Value = "-1"
objMailItem.Save
Next objMailItem
Next SubFolder
End Sub
Any help greatly appreciated as I have made countless attempts.
The coding (generally) used to create the UDF was:
Sub AddFolders(CurrentFolder As Outlook.Folder, TabChars, ByRef Report As String)
Dim SubFolder As Outlook.Folder
Dim objFolder As Object
Dim myUserProperty As Outlook.UserDefinedProperty
Dim objMailItem As Object
Dim intItemsCount As Integer
Dim strAddImported As String
strAddImported = "Imported"
For Each SubFolder In CurrentFolder.Folders
Set objFolder = SubFolder
Set myUserProperty = SubFolder.UserDefinedProperties.Add("Imported", olYesNo, True)
myUserPropery.UserProperties.Value = False
Attempts to change UDF values generally look as follows (it works for Mail Items I have manually used the UDF, but will not work for those I have not manually used):
For Each objMailItem In objFolder.Items
objMailItem.UserProperties(strAddImported).Value = False
objMailItem.Save
objMailItem.UserProperties(strAddImported).Value = "-1"
objMailItem.Save
Next objMailItem
Next SubFolder
End Sub
Any help greatly appreciated as I have made countless attempts.