views:

4190

answers:

2

So, I want to export all my contacts from Outlook as vcards. If I google that, I get a bunch of shareware programs, but I want something free that just works.

If I'm to code it myself, I guess I should use the Microsoft.Office.Interop.Outlook assembly. Has anyone already code to convert ContactItems to vcards?

Edit: I solved it in a completely different way, see answer below, but I have marked dok1.myopenid.com's answer as accepted because it answers my original question.

+2  A: 

They sure make it hard to find, don't they? See if this helps. http://msdn.microsoft.com/en-us/library/aa579624(EXCHG.80).aspx

That includes: The following example uses the CDO Person object to obtain vCard information for a contact.

Dim oPerson As New CDO.Person
Dim strm As New ADODB.Stream

' Assume strURL is a valid URL to a person contact item
oPerson.DataSource.Open strURL

' You can set the ADO Stream object to the returned vCard stream
Set strm = oPerson.GetvCardStream

' Save the stream to a file.
' Note: using adSaveCreateOverwrite may cause an existing
' contact to be overwritten.
strm.SaveToFile "d:\vcard.txt", adSaveCreateOverwrite

' You don't have to set a Stream object,
' just use the Stream methods off GetvCardStream directly
oPerson.GetvCardStream.SaveToFile "d:\vcard.txt", adSaveCreateOverwrite

Yep, the only code sample there is in VB.

DOK
+4  A: 

I solved it in a non-programmatically way:

  • Selected all contacts in Outlook
  • Forwarded them as cards to myself
  • Saved all the attachments (vcards) in a folder, c:\temp
  • Opened a command prompt and typed the command copy /a *.vcf c:\allcards.vcf which concatenates all vcards into one
Jonas Lincoln