function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
joshDDUPjoshDDUP 

Can I control the mime-type of the S-Control Window?

I'd like to write an s-control using the Ajax toolkit but I’d like the window that opens up to be of a specific mime (sub) type!

Not HTML!!!! Can this be done?

Thx in advance,

joshDDUPjoshDDUP
Here is how you can "export" a contact to vCard using visualForce:
  1. create a page with the code below / set security properly... assume name: Contact_vCard
  2. create/add a custom link (or button) on contact page layout (I used open New Window): /apex/Contact_vCard?id={!Contact.Id}
Code:
<apex:page standardController="Contact" contenttype="text/x-vcard">

BEGIN:VCARD
VERSION:2.1
N:{!Contact.LastName};{!Contact.FirstName}
FN:{!Contact.FirstName} {!Contact.LastName}
ORG:{!Contact.Account.Name}
TITLE:{!Contact.Title}
TEL;WORK;VOICE:{!Contact.Phone}
TEL;WORK;FAX:{!Contact.Fax}
TEL;WORK;Cell:{!Contact.MobilePhone}
TEL;HOME;VOICE:{!Contact.HomePhone}
ADR;WORK:;;{!Contact.MailingStreet};{!Contact.MailingCity};{!Contact.MailingState};{!Contact.MailingPostalCode};{!Contact.MailingCountry}
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:{!Contact.MailingStreet}=0D=0A{!Contact.MailingCity}, {!Contact.MailingState} {!Contact.MailingPostalCode}=0D=0A{!Contact.MailingCountry}
EMAIL;PREF;INTERNET:{!Contact.Email}
NOTE;ENCODING=QUOTED-PRINTABLE:Exported from -->Organization Name<-- salesforce.com CRM application=0D=0A*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*=0D=0A{!Contact.Description}
END:VCARD

</apex:page>

RivoRivo

Apologies for bumping this, but I have recreated the VF page and link as per instruction within the thread, however when clicking link, I get the following error:

 

"Internet Explorer cannot download Contact_vcard from c.eu0.visual.force.com.

 

Internet Explorer was not able to open this internet site. The requested site is either unavailable or cannot be found. Please try again later."

 

Does anyone have any ideas?

mwozniakmwozniak

I was also checking into an option to create v-cards, and after some digging, found the following information in the help guides:

 

contentTypeThe MIME content type used to format the rendered page. Possible values for this attribute include any type that can be generated using a text-based generator, including "text/html", "application/vnd.ms-excel", and "text/css". For more information, including a complete list of possible values, see http://www.iana.org/assignments/media-types/. You can also define the filename of the rendered page by appending a # followed by the file name to the MIME type. For example, "application/vnd.ms-excel#contacts.xls". Note, some browsers will not open the resulting file unless you specify the filename and set the cache attribute on the page to "true".

 

So for testing purposes, I used my User First Name and Last Name to create a test vcard with the following code:

 

<apex:page standardController="User" showHeader="False" cache="True" contenttype="text/x-vcard#TempImport.vcf">
BEGIN:VCARD
VERSION:2.1
FN:{!$User.FirstName} {!$User.LastName}
END:VCARD
</apex:page>

 

This code worked for me, and I was able to download the v-card. (I am using Windows XP Pro and Office 2007). Hope this helps!