How to replicate the Outlook Application's Default Behaviour?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 08:09
Joined
Mar 22, 2009
Messages
916
My client has more 11,000 contacts in his android phone.
I backed it up to a pendrive in a single vcf file (37 MB).
Initially I had some challenges on splitting the contacts inside that mother vcf file to single vcf files.
Now I have more than 11,000 individual vcf files in a folder.
The current challenge is to upload into outlook for further classification.
Exact Problem:
I don't want to write a loop for each contact fields present in the vcf files. Instead, I want it to happen like the way Outlook does import single vcf files. (The contact fields are populated without any further options or process). Possible? Thanks for reading and willing to answer :)
 
a loop in outlook vba might work? have you tried one or gotten started on it?
 
a loop in outlook vba might work? have you tried one or gotten started on it?
Code:
Sub ImportVCFFilesIntoGroup()
    
    ' Set folder path containing VCF files
    Const vcfFolderPath As String = "C:\Users\arrow\OneDrive\Documents\Contacts\"
    
    ' Set contact group name
    Const groupName As String = "BOSS"
    
    ' Create Outlook application object
    Dim olApp As New Outlook.Application
    
    ' Get Contacts folder
    Dim olContacts As MAPIFolder
    Set olContacts = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    
    ' Get or create contact group
    Dim olGroup As MAPIFolder
    On Error Resume Next
    Set olGroup = olContacts.Folders(groupName)
    If olGroup Is Nothing Then
        Set olGroup = olContacts.Folders.Add(groupName)
    End If
    On Error GoTo 0
    
' Initialize file variable
    Dim vcfFile As String
    
    ' Get first file
    vcfFile = Dir(vcfFolderPath & "*.vcf")
    
    ' Iterate through VCF files in folder
    While vcfFile <> ""
        ' Create new contact item from VCF file
        Dim olContact As ContactItem
        Set olContact = olApp.GetNamespace("MAPI").OpenSharedItem(vcfFolderPath & vcfFile)
        olContact.Save
        ' Move contact to group
        olContact.Move olGroup
        
        ' Release object
        Set olContact = Nothing
        
        ' Get next file
        vcfFile = Dir
    Wend
    
    
    ' Release objects
    Set olGroup = Nothing
    Set olContacts = Nothing
    Set olApp = Nothing
    
    MsgBox "VCF files imported successfully into group '" & groupName & "'!"
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom