Automatically add contacts from a vCard attachment

H

humble

Is it possible to take a vCard attached in an email and automatically import
it as a new contact.

I have some code that loops through each mail in a folder and gets the
attachment, but I don't seem to be able to save it as a contact.

Any ideas - Current vba code shown below
Thanks

Jon

Sub importAddresses()
Dim myNameSpace As NameSpace
Dim myFolder As MAPIFolder
Dim myContact As ContactItem
Dim myTempContact As ContactItem
Dim myItem As MailItem
Dim myAttachment As Attachment

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
For i = 1 To myNameSpace.Folders.Count
Set thisFolder = myNameSpace.Folders.Item(i)
For j = 1 To thisFolder.Folders.Count
sTemp = thisFolder.Folders.Item(j).Name
If sTemp = "Temp" Then
Set myFolder = thisFolder.Folders.Item(j)
MsgBox (myFolder.Items.Count)
For k = 1 To myFolder.Items.Count
Set myItem = myFolder.Items.Item(k)
If myItem.Attachments.Count = 1 Then
MsgBox (myItem.Attachments.Item(1).FileName)
Else
MsgBox ("There are " + Str(myItem.Attachments.Count)
+ " Attachments for " + myItem.Subject)
End If
Next
End If
Next
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top