Export to vCard

I’ll work on this tomorrow @jim.malmberg38

Once finished it should be prompted automatically on the user’s phone or at least this is the goal.

Hi Jim,

If you try the project I linked above, it’ll open a fake contact card – or at least, it does on iPhone, and then there’s an ‘add contact’ button at the end. :slight_smile: It’s proof of principle that it’ll work, not yet a working version.

Good night, @muneer! :slight_smile:

(updated - also on Android/Kindle, although I had to click ‘open’ after it downloaded.)

1 Like


I updated the project to make it workable. I found that in Android, it did not accept the file after being downloaded. I can see it and see that all information is saved but the contact app on the phone doesn’t want to import it.

I searched in the net and found that a vCard file is not a text but it is actually a binary file (8 bit bytes or extended ASCII) so I had to try different file formats and found that my phone accepted the generated file when I used file type of application/octet-stream.

I need you to test it so we can say it works on different phones.

Export vCard

If it works, I’ll put it as part of the WDC so people can benefit from it.

Emoorted vCard Example

Good job @muneer, it works well for me.

1 Like

My iphone asks if it should download but does not open it. It’s possible you need some OS-specific code, since it was working for iphone yesterday.

Updated: Yep. My phone wants this as the file-type instead:

Also, I think you have first and last names reversed?

1 Like

Thank you for the confirmation about file types. I’ll check on my end to see if it works for Android too.

I saw that the names are reversed but as it is a proof of concept and didn’t bother to fix it.

Thanks again.

Yes, I tested the file type “text/vcard” and it works for Android too.

HTML file required for the app

1 Like

Thanks for posting it!

@jim.malmberg38 , if you have questions on how to use @muneer’s work, post 'em and we’ll get you squared away. To summarize what I think you need to do:

Muneer’s prototype takes text inputs. Use his work as a model to plug in your google sheets values instead. If you want to include additional information (address, company, etc), you’ll just need to look up the VCARD standard and pass that in as well. Note that content-data needs to be url-encoded. You can see where Muneer did it for spaces (and carriage returns around the BEGIN and END text). If you expect other problem characters, you’ll need to do the same.

You’ll need to put the file he provided somewhere on the internet, with a .html ending. There are free options, including github, blogger, etc, that will let you serve an HTML file with built-in javascript. You need to update the URL in muneer’s example to point at that URL. I’d also consider adding some basic HTML content so that the user doesn’t get a blank screen in the browser.

1 Like

Many thanks for the explanation.

See a vCard sample file attached

vcard-format.txt (909 Bytes)

1 Like

Sorry for the late response. I just tried this and it downloaded it. Txt file to my phone. I changed it to vcf and tried to imported but that didn’t work. What am I doing wrong here?

1 Like

Which version of the project are you using? And what type of phone?

You aren’t trying to install muneer’s createfile.txt as a vcf are you? (Sorry if that’s a silly question - I find it good to rule out the easy problems first.)

1 Like


Just delete the project you previously copied and remix this one instead.

It seems the Drive-To-Web is a bit slow. I uploaded the HTML file in my Github account and updated the project to point to it.

Interesting. It took me a while to figure out what was happening with the file. The file name threw me off because it comes out something like “just_a_file.vcf” but it went into my address book with your name. Don’t know if that was the intent since the only thing I wrote in the text box was “test.”

Still looking through all of your and @muneer 's notes. Thank you both for your work on this!

1 Like

Thank you!

1 Like

@muneer your Export VCard 3 worked great for me.

1 Like

Muneer (@muneer) & Cathy (@catsarisky ),

Before I start incorporating this, I want to make sure that I understand the blocks so I’ve got a few questions.

  1. In the Export to Vcard program, the user is typing out the fields. Is there any reason that I can’t set the field values based on the already populated labels on the screen in my program? Cathy, you had mentioned taking the values from the Google sheet but labels will already be filled from that data source so I was thinking they would be more efficient. Do you agree?

  2. I want to make sure that I understand The CreateFile.txt use. I would take the html code in it and park it at a URL. Then I point my blocks to that URL. Is that correct?

  3. With regard the the vCards themselves, I’m not seeing anything in the html code that refers to specific fields. Does that mean that it operates independently of the fields, so that I can include any fields I want as long as the vCard format is followed?

  4. In the vCard file save, I see seconds since 1970. Is that just to make sure that all of the file names are unique? If so, can I replace that with the individual’s first and last names, again taken from the labels in my program?

I think that’s it for the moment.

Again I really appreciate the work that both of you have done on this!!! I’m pretty much a beginner and there is no way that would be anywhere near as far along on this without your assistance.

Thank you both!!!


1 Like
  1. There’s no reason you can’t just directly use the values from the google sheet. You /could/ set text inputs, but I don’t see a reason to let the user edit the vcard. (Maybe you do.) Muneer’s buildcard function could be adjusted to do that pretty easily, and you can add any (valid) fields to the vcard you want just by adjusting it.

  2. Yes, you need to put the full contents of createfile.txt on a website somewhere, and point your blocks at that URL. Note that everything in Muneer’s example from the ? onward is the query text for that page, NOT part of the URL itself.

  3. Right, the javascript (on the html page) just takes and returns whatever you pass it as content-data, so you can pass anything you want, with limits that if the phone receiving it doesn’t recognize the fields, that may not work well. :slight_smile:

  4. You can pass back the file with any name you want. I’d put a .vcf on the end to help the phone recognize it, but the name of the file is not important, and you can use whatever you want.

1 Like

Sorry for any confusion - I was too lazy to type valid text in the boxes while I was playing with just getting the phone to recognize it. The final project muneer posted is the best starting point, for sure.

1 Like

Thank you! Now, I’ll start playing around with it. I’m sure that I’ll have more questions as I move along.

1 Like

You know where to find us if you do! :slight_smile: