I'm trying to create VCard on the fly for a site. I simply open a "real" VCard once create with Outlook with Notepad++ and saw what I need into it to create one on the fly. Everything works fine and I'm able to add anything I need, where I need. Instead one point :
I've add everything suggested by the Outlook created one who's proposing to add : "CHARSET=Windows-1252:" in front of my string entry (also tryied ISO-8859-1, UTF8, UTF7, UTF-8, UTF-7) and none of those are working.
Any suggestion?
EDIT (After Alexandre C.'s answer)
Here is the VCard source. Please note that the source shows it correctly, but when I open it with Outlook, I still have the accent problem :
BEGIN:VCARD VERSION:2.1
N;LANGUAGE=fr-ca;CHARSET=UTF-8:Dugré;Simon
ORG;CHARSET=utf-8:CompanyNameéàêâç
TEL;WORK;VOICE:5555555555
X-MS-OL-DEFAULT-POSTAL-ADDRESS:0
EMAIL;PREF;INTERNET:[email protected]
X-MS-OL-DESIGN;CHARSET=utf-8:[VCard HTML Format]
REV:20110404T135700
END:VCARD
You should write CHARSET=utf-8
and not CHARSET=UTF-8
.
vCard specs suggest that character set should be case independent, but Outlook does not care.
Here is the good line:
currentPage.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0} {1}.vcf", this.FirstName, this.LastName));
currentPage.Response.ContentType = "text/x-vcard";
currentPage.Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); // THIS LINE
currentPage.Response.Write(content);
currentPage.Response.End();
Instead of :
currentPage.Response.Charset = "ISO-8859-1";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With