Solved

How to export Access contact record to vCard?

Posted on 2004-09-24
13
3,000 Views
Last Modified: 2016-11-19
Hello - how would one go about exporting a typical contact record from an Access (XP) table to a vCard?

Thanks

Mark
0
Comment
Question by:mlagrange
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12144337
Can you export it as a CSV file (File->Export) and import it into your target application?
0
 

Author Comment

by:mlagrange
ID: 12144737
Well, my impression of the whole vCard thing was that all the recepient had to do was click on the vCard icon, and it would automatically import the contact info into Outlook.

After looking at the contents of a .vcf file, I can imagine that there must be some rules about field names, multiple values for a given field, etc.

Not to mention how to attach it to an e-mail so it would get processed like a vCard...

That's what I'm really looking for

Thanks

Mark
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12144760
Sorry, I'm not really familiar with vcf files. You'd have to write some kind of VBA function to export the record in the format desired, but I don't know of any pre-written code offhand. How familiar are you with VBA coding?
0
 

Author Comment

by:mlagrange
ID: 12144868
familiar with VBA coding: yes... oh, yes...
familiar with vcf files: no
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12145041
Here are the official specs for vCards:

http://www.imc.org/pdi/
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12145940
Hmm, it seems that Access 2003 can export directly to a .vcf file, but Access 2002 (XP) can't. Briefly scanning the spec, it seems reasonably straightforwards to create one programmatically but I don't really have time to investigate the full spec document.

In brief though, you'd open a file programmatically, open a recordset with the record you want to export and then write out each field in the format required - placing the header and footer information as required.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 250 total points
ID: 12146206
I would reccomend you either create a VCard file from Outllook or just view one that you have and copy the template in your code to determine to properties that you need to export. I took one (it had bare minimum data) and copied it to create the following:

Sub CreateVCard()

    Dim c As ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim vcInfo As String
   
    'Set the provider name
    Set c = CurrentProject.Connection
    'Open a recordset with a keyset cursor
    rs.Open "Select Top 3 * From [CompiledInfo]", c, adOpenKeyset, adLockPessimistic

    If Not rs.EOF And Not rs.BOF Then
        rs.MoveFirst
        Do Until rs.EOF
            vcInfo = "BEGIN:VCARD" & vbCrLf
            vcInfo = vcInfo & "VERSION:2.1" & vbCrLf
            vcInfo = vcInfo & "N:" & rs!LastName & ";" & rs!Title & rs!FirstName & rs!MiddleName & ";" & rs!FullName & vbCrLf
            vcInfo = vcInfo & "FN:" & rs!FullName & vbCrLf
            vcInfo = vcInfo & "EMAIL;PREF;INTERNET:" & rs!Email1Address & vbCrLf
            vcInfo = vcInfo & "END:VCARD"
            Call PrintVCard(vcInfo, rs!FullName)
            rs.MoveNext
        Loop
    End If

    rs.Close
    Set rs = Nothing
    Set c = Nothing
   
End Sub

Function PrintVCard(vcInfo As String, flName As String)
    Open "C:\Temp\" & flName & ".vcf" For Output As #1    ' Open file for output.
    Print #1, vcInfo
    Close #1
End Function
0
 

Author Comment

by:mlagrange
ID: 12147415
Great, and thank you.

Now, is there a trick to get this attached to a mail message, so that it functions like a vCard for the recipient?

Thanks

Mark
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12147997
The  code above creates a VCard, so all you'd need to do is write the code for creating youremail object then add the attachment sort of like this:

myMailObject.Attachments.add "C:\Temp\ & flName & ".vcf"
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12149579
ThanX for the points! Glad I could help.

God bless!

Sam
0
 

Author Comment

by:mlagrange
ID: 12150352
Hey, Thank You!

I'm glad you could help, too!  :-D

Mark
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12150416
I realised I was a little short on help about creating the e-mail. I appologise for that. I was on my way to bed (it was midnight). If you need help creating an e-mail in code let me know and I can post some more details.
0
 

Expert Comment

by:Charles Pendrigh
ID: 41894245
Don't you just love it when a 'Best Solution' award is given to a post which doesn't answer the question.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Explanation of Access VBA code 2 35
Open a Specific Record With a Specific Tab Page 5 28
Access query with left expression 9 31
combine ShipTo and BillTo Address 3 22
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now