come aprire vCard per impostazione predefinita in Outlook 2007/03?
Domanda
Ho generato il vCard da asp.net + C #. Mentre finendo. browser scatta verso l'alto per "aperto con / Salva con nome" scatola. Non voglio apparire questa casella. piuttosto che quello, voglio impostare direttamente il generato .vcf file da aprire con Outlook 2007 o 03. cosa HAE fare? Il mio codice è:
S
ystem.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
//vCard Begin
stringWrite.WriteLine("BEGIN:VCARD");
stringWrite.WriteLine("VERSION:2.1");
//Name
stringWrite.WriteLine("N:" + nameLast + ";" + nameFirst +
";" + nameMiddle + ";" + nameTitle);
//Full Name
stringWrite.WriteLine("FN:" + nameFirst + " " +
nameMiddle + " " + nameLast);
//Organisation
stringWrite.WriteLine("ORG:" + company + ";" + department);
//URL
stringWrite.WriteLine("URL;WORK:" + uRL);
//Title
stringWrite.WriteLine("TITLE:" + title);
//Profession
stringWrite.WriteLine("ROLE:" + profession);
//Telephone
stringWrite.WriteLine("TEL;WORK;VOICE:" + telephone);
//Fax
stringWrite.WriteLine("TEL;WORK;FAX:" + fax);
//Mobile
stringWrite.WriteLine("TEL;CELL;VOICE:" + mobile);
//Email
stringWrite.WriteLine("EMAIL;PREF;INTERNET:" + email);
//Address
stringWrite.WriteLine("ADR;WORK;ENCODING=QUOTED-PRINTABLE:" + ";" +
office + ";" + addressTitle + "=0D" +
streetName + ";" + city + ";" +
region +
";" + postCode + ";" + country);
//Revision Date
//Not needed
//stringWrite.WriteLine("REV:" + DateTime.Today.Year.ToString() +
// DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + "T" +
// DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() +
// DateTime.Now.Second.ToString() + "Z");
//vCard End
stringWrite.WriteLine("END:VCARD");
response.Write(stringWrite.ToString());
response.AppendHeader("Hi", "PMTS");
response.End();
Soluzione
Se ti sto comprensione correttamente, il problema è che si sta ricevendo una finestra run-o-download quando si intende per il vCard semplicemente aperto dal web.
Supponendo che è in realtà quello che hai intenzione, ti credo deve solo impostare la risposta a uno dei tipi MIME vCard (text/x-vcard
, text/directory;profile=vCard
o text/directory
).
Response.ContentType = "text/x-vcard";
Mi auguro che aiuta.
- EDIT -
utilizzando il seguente codice, sto correttamente chiesto di aprire o salvare (e Open apre il file in Outlook) in Internet Exploder. Purtroppo, Chrome ancora non supporta i file di apertura a quanto pare, e così c'è una casella di scaricare un po 'in modo permanente a quanto pare. Provate il seguente codice in IE e vedrete cosa intendo; Funziona. Inoltre, in una nota a margine - sarei stato in grado di replicare il codice di un po 'più facile se formattata correttamente. Ogni possibilità è possibile modificare il tuo post, evidenziare il codice, e ha colpito l'icona "101010"? Grazie molto, e buona fortuna!
using System;
using System.IO;
using System.Web.UI;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
private string nameLast = "May";
private string nameFirst = "Lance";
private string nameMiddle = "R.";
private string nameTitle = "Mr.";
private string company = "CoreLogic";
private string department = "Development";
private string uRL = "http://www.lancemay.com";
private string title = "Application Developer Senior";
private string profession = "Developer";
private string telephone = "(123) 555-1212";
private string fax = "(321) 555-1212";
private string mobile = "(555) 555-1212";
private string email = "lancemay@gmail.com";
private string office = "Louisville";
private string addressTitle = "";
private string streetName = "123 Easy St.";
private string city = "Louisville";
private string region = "KY";
private string postCode = "40223";
private string country = "US";
protected void Page_Load(object sender, EventArgs e)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
//vCard Begin
stringWrite.WriteLine("BEGIN:VCARD");
stringWrite.WriteLine("VERSION:2.1");
//Name
stringWrite.WriteLine("N:" + nameLast + ";" + nameFirst + ";" + nameMiddle + ";" + nameTitle);
//Full Name
stringWrite.WriteLine("FN:" + nameFirst + " " + nameMiddle + " " + nameLast);
//Organisation
stringWrite.WriteLine("ORG:" + company + ";" + department);
//URL
stringWrite.WriteLine("URL;WORK:" + uRL);
//Title
stringWrite.WriteLine("TITLE:" + title);
//Profession
stringWrite.WriteLine("ROLE:" + profession);
//Telephone
stringWrite.WriteLine("TEL;WORK;VOICE:" + telephone);
//Fax
stringWrite.WriteLine("TEL;WORK;FAX:" + fax);
//Mobile
stringWrite.WriteLine("TEL;CELL;VOICE:" + mobile);
//Email
stringWrite.WriteLine("EMAIL;PREF;INTERNET:" + email);
//Address
stringWrite.WriteLine("ADR;WORK;ENCODING=QUOTED-PRINTABLE:" + ";" + office + ";" + addressTitle + "=0D" + streetName + ";" + city + ";" + region + ";" + postCode + ";" + country);
stringWrite.WriteLine("END:VCARD");
Response.ContentType = "text/x-vcard";
Response.Write(stringWrite.ToString());
Response.AppendHeader("Hi", "PMTS");
Response.End();
}
}
}