Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create vCard CFML?

New Here ,
Sep 06, 2007 Sep 06, 2007
Has anyone ever written a CFML script to create a vCard from data returned from a database.

For instance, we have our company intranet which runs on ColdFusion which was designed by me. You can do a customer lookup by lastname, and it shows the customer data in a nicely layed out cfm page. Is there a way to auto-generate a vcard file from the returned data and make it a downloadable vcard with link? I am a novice when it comes to CFML so cannot figure it out on my own.

Thanks for the help.
Nick
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 06, 2007 Sep 06, 2007
A couple are in the Adobe Exchange

http://www.adobe.com/cfusion/exchange/index.cfm?searchfield=vcard&search_exchange=&num=25&startnum=1...

And a vCal udf I wrote awhile back targeted towards calendar data
http://www.cflib.org/udf.cfm?ID=385
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 06, 2007 Sep 06, 2007
I have tried the following:

<cfsetting enablecfoutputonly="Yes" showdebugoutput="No">
<cfparam name="attributes.Last" default="">
<cfparam name="attributes.FullName" default="">
<cfparam name="attributes.Middle" default="">
<cfparam name="attributes.Title" default="">
<cfparam name="attributes.Suffix" default="">
<cfparam name="attributes.Company" default="">
<cfparam name="attributes.JobTitle" default="">
<cfparam name="attributes.BusinessPhone" default="">
<cfparam name="attributes.HomePhone" default="">
<cfparam name="attributes.MobilePhone" default="">
<cfparam name="attributes.BusFax" default="">
<cfparam name="attributes.city" default="">
<cfparam name="attributes.Street" default="">
<cfparam name="attributes.Address1" default="">
<cfparam name="attributes.Address2" default="">
<cfparam name="attributes.StateProv" default="">
<cfparam name="attributes.ZipPostal" default="">
<cfparam name="attributes.Country" default="">
<cfparam name="attributes.CountryRegion" default="">
<cfparam name="attributes.WebPage" default="">
<cfparam name="attributes.vCardFileName" default="Yourfilename">
<cfparam name="attributes.vCardDirectory" default="c:\vcards\">
<cfset REV = "#year(now())#-#numberformat(month(now()),"00")#-#numberformat(day(now()),"00")#">
<cfcontent reset="Yes">
<cfoutput><cfsavecontent variable="vCard">BEGIN:VCARD
VERSION:3.0

N:#customer.lastname#;#customer.firstname#;;;

FN:#customer.company#

ORG:#customer.company#

EMAIL;type=INTERNET;type=WORK;type=pref:#customer.emailaddress#

TEL;type=WORK;type=pref:#customer.phone#

TEL;type=WORK;type=FAX:#customer.fax

item1.URL;type=pref:

item1.X-ABLabel:Credit Card

X-ABShowAs:COMPANY
END:VCARD</cfsavecontent></cfoutput><cfset fileid=createuuid()>
<cfif not(directoryexists("#attributes.vCardDirectory#"))>
<cfdirectory action="CREATE" directory="#attributes.vCardDirectory#">
</cfif>

<cffile action="WRITE" file="#attributes.vCardDirectory##fileid#.vcf" output="#vCard#" addnewline="Yes">
<CFHEADER NAME="Content-Disposition" VALUE="inline; filename=#attributes.vCardFileName#.vcf">
<cfcontent type="application/vcard" file="c:\cvards\#fileid#.vcf" reset="Yes" deletefile="Yes"><cfabort>


The only error I get is form my address book saying that no importable vcard is found. Am I missing something in the coding? I look at the vcard file it creates and the correct data is there. Am I not calling the vcard back from the correct spot?

Thanks again.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 06, 2007 Sep 06, 2007
Ok, so everything else works except for the recall.

When I download the file it comes in with the correct filename but nothing in the file itself. When I look on the server where the file is located, data is inside of it. When I download the file, there is no data present.

Any ideas?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 07, 2007 Sep 07, 2007
Does the same script work if you do not write to the file system and do not use <cfsetting../> at the top of your script? eg:

<cfparam name="attributes.Last" default="">
....
END:VCARD
</cfsavecontent>
</cfoutput>
<CFHEADER NAME="Content-Disposition" VALUE="inline; filename=#attributes.vCardFileName#.vcf">
<cfconent type="application/vcard" reset="true"/><cfoutput>#vCard#</cfoutput><cfabort>

Also, maybe try your mimetype as 'text/x-vcard' and make sure the web server is set up to recognise this mime type.

If it still doesn't work, can you ensure that the 'vCard' variable is actually populated by dumping/aborting before the cfcontent tag runs?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 07, 2007 Sep 07, 2007
None of that works. It is weird, it returns the file, but returns it with no text in the file. When I look at the file it created on the server, it has the text in it.

Very weird!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2007 Oct 28, 2007
Nick,

Did you every get this to work? If so, I'd be interested in seeing your final solution.

Roger
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2007 Oct 28, 2007
LATEST
I do not know that the origanle message is but you might try this. I cannot
find this tag any longer but this might help.

************ Useage ***************
<cf_vCalendar StartDate = "2/01/07"
StartTime = "10:00 AM"
EndDate = "2/01/07"
EndTime = "10:30 AM"
Summary = "MEETING"
Location = "Web"
Description = "https://www.gotomeeting.com/join/536910997
Conference Call: Call In: 1-555-206-0240 Participant Pin 387577##"
FilePath = "c:\Inetpub\cal\Feb1.vcs"
LinkURL = "/cal/Feb1.vcs"
LinkText = "Click here to add this event to your calendar">
************ Useage ***************



********** Tag ***************

<!--
Custom tag: cf_vCalendar
Author: Minh Lee Goon
Date: June 23, 2003
License: This tag may be used freely. You may modify this tag as you see
fit.
However, this header must remain intact.
Disclaimer: This tag is provided as is. I make no warranty or guarantee.
Use of
this tag is at your own risk. Please contact me with bug fixes and/or
improvements.
Contact: MinhLee@Goonies.info
-->

<!--- Default: Initialize variables --->
<cfparam name="attributes.StartDate" default="">
<cfparam name="attributes.StartTime" default=#CreateTime("8", "0", "0")#>
<cfparam name="attributes.EndDate" default=#attributes.StartDate#>
<cfparam name="attributes.EndTime" default=#CreateTime("17", "0", "0")#>
<cfparam name="attributes.Location" default="Not applicable">
<cfparam name="attributes.Description" default="">
<cfparam name="attributes.Summary" default="">
<cfparam name="attributes.FilePath" default="">
<cfparam name="attributes.LinkURL" default="">
<cfparam name="attributes.LinkText" default=#attributes.Summary#>

<!--- Condition: Abort tag if required fields are not defined --->
<cfif (attributes.StartDate is "") or (attributes.Summary is "") or
(attributes.LinkURL is "") or (attributes.FilePath is "")>
<cfabort showerror="The following attributes are required: FilePath,
LinkURL, StartDate, Summary">
</cfif>

<!--- Condition: Hard-set dates and times, if not defined in custom tag.
Verify date/time values --->
<cfif (IsDate(attributes.StartDate) is "No")>
<cfabort showerror="All date/time fields must be able to be converted to
values.">
</cfif>
<cfif attributes.StartTime is "">
<cfset attributes.StartTime=#CreateTime("8", "0", "0")#>
<cfelse>
<cfif (IsDate(attributes.StartTime) is "No")>
<cfabort showerror="All date/time fields must be able to be converted to
values.">
</cfif>
</cfif>
<cfif attributes.EndDate is "">
<cfset attributes.EndDate=#attributes.StartDate#>
<cfelse>
<cfif (IsDate(attributes.EndDate) is "No")>
<cfabort showerror="All date/time fields must be able to be converted to
values.">
</cfif>
</cfif>
<cfif attributes.EndTime is "">
<cfset attributes.EndTime=#CreateTime("17", "0", "0")#>
<cfelse>
<cfif (IsDate(attributes.EndTime) is "No")>
<cfabort showerror="All date/time fields must be able to be converted to
values.">
</cfif>
</cfif>

<!--- Set: Date/Time information --->
<cfset dtStart=#CreateDateTime(Year(attributes.StartDate),
Month(attributes.StartDate), Day(attributes.StartDate),
Hour(attributes.StartTime), Minute(attributes.StartTime),
Second(attributes.StartTime))#>
<cfset dtEnd=#CreateDateTime(Year(attributes.EndDate),
Month(attributes.EndDate), Day(attributes.EndDate),
Hour(attributes.EndTime), Minute(attributes.EndTime),
Second(attributes.EndTime))#>
<!--- Set: Get time zone information --->
<cfset TimeZoneInfo=GetTimeZoneInfo()>

<!--- File: Create and append vCalendar information to the specified
file --->
<cffile action="write" file="#attributes.FilePath#"
output="BEGIN:VCALENDAR">
<cffile action="append" file="#attributes.FilePath#"
output="PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN">
<cffile action="append" file="#attributes.FilePath#" output="VERSION:1.0">
<cffile action="append" file="#attributes.FilePath#" output="BEGIN:VEVENT">
<cffile action="append" file="#attributes.FilePath#"
output="DTSTART:#DateFormat(dtStart, "yyyymmdd")#T#TimeFormat(DateAdd("h",
TimeZoneInfo.UTCHourOffset, dtStart), "HHmmss")#Z">
<cffile action="append" file="#attributes.FilePath#"
output="DTEND:#DateFormat(dtEnd, "yyyymmdd")#T#TimeFormat(DateAdd("h",
TimeZoneInfo.UTCHourOffset, dtEnd), "HHmmss")#Z">
<cffile action="append" file="#attributes.FilePath#"
output="LOCATION;ENCODING=QUOTED-PRINTABLE:#attributes.Location#">
<cffile action="append" file="#attributes.FilePath#"
output="DESCRIPTION;ENCODING=QUOTED-PRINTABLE:#attributes.Description#">
<cffile action="append" file="#attributes.FilePath#"
output="SUMMARY;ENCODING=QUOTED-PRINTABLE:#attributes.Summary#">
<cffile action="append" file="#attributes.FilePath#" output="PRIORITY:3">
<cffile action="append" file="#attributes.FilePath#" output="END:VEVENT">
<cffile action="append" file="#attributes.FilePath#" output="END:VCALENDAR">

<cfoutput>
<a href="#attributes.LinkURL#">#attributes.LinkText#</a>
</cfoutput>
****************** Tag *******************




"drmaves" <drmaves@iglide.net> wrote in message
news:fg285n$q71$1@forums.macromedia.com...
> Nick,
>
> Did you every get this to work? If so, I'd be interested in seeing your
> final solution.
>
> Roger


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources