excelbeginner
New Member
- Outlook version
- Outlook 2016 64 bit
- Email Account
- Exchange Server
Hi I have no VBA background, and I will like to know how do I convert import data to custom fields in task list.
I understand i have to first map to the default fields then copy the default fields values to my own user created fields. Will anyone able to assist?
The closest solution i came across so far is the code below but it is for contact management, anyone able to help modify the code below to make it applicable for tasklist?
Sub ConvertFields()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItems As Items
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
Set objItems = objFolder.Items
For Each objItem In objItems
' make sure you have a Contact item
If objItem.Class = olContact Then
' convert to your published custom form
objItem.MessageClass = "IPM.Contact.Custom"
' copy data to your custom fields
objItem.UserProperties("Custom1") = objItem.User1
objItem.UserProperties("Custom2") = objItem.User2
objItem.UserProperties("Custom3") = objItem.User3
objItem.UserProperties("Custom4") = objItem.User4
objItem.User1 = ""
objItem.User2 = ""
objItem.User3 = ""
objItem.User4 = ""
objItem.Save
End If
Next
End If
Set objItems = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
I understand i have to first map to the default fields then copy the default fields values to my own user created fields. Will anyone able to assist?
The closest solution i came across so far is the code below but it is for contact management, anyone able to help modify the code below to make it applicable for tasklist?
Sub ConvertFields()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItems As Items
Dim objItem As Object
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
Set objItems = objFolder.Items
For Each objItem In objItems
' make sure you have a Contact item
If objItem.Class = olContact Then
' convert to your published custom form
objItem.MessageClass = "IPM.Contact.Custom"
' copy data to your custom fields
objItem.UserProperties("Custom1") = objItem.User1
objItem.UserProperties("Custom2") = objItem.User2
objItem.UserProperties("Custom3") = objItem.User3
objItem.UserProperties("Custom4") = objItem.User4
objItem.User1 = ""
objItem.User2 = ""
objItem.User3 = ""
objItem.User4 = ""
objItem.Save
End If
Next
End If
Set objItems = Nothing
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub