C# 如何在outlook 2007/03中默认打开vCard?

C# 如何在outlook 2007/03中默认打开vCard?,c#,asp.net,outlook,vcf-vcard,C#,Asp.net,Outlook,Vcf Vcard,我已经从asp.net+c应用程序生成了vCard。在结束的时候。浏览器弹出“打开/另存为”框。我不想出现在这个盒子里。相反,我希望直接将生成的.vcf文件设置为使用outlook 2007或03打开。你该怎么办? 我的代码是: 如果我理解正确的话,问题是当你想让vCard直接从网络上打开时,你会得到一个运行或下载对话框 假设这正是您想要的,我相信您只需将响应设置为vCard MIME类型之一(text/x-vCard,text/directory;profile=vCard,或text/di

我已经从asp.net+c应用程序生成了vCard。在结束的时候。浏览器弹出“打开/另存为”框。我不想出现在这个盒子里。相反,我希望直接将生成的.vcf文件设置为使用outlook 2007或03打开。你该怎么办? 我的代码是:


如果我理解正确的话,问题是当你想让vCard直接从网络上打开时,你会得到一个运行或下载对话框

假设这正是您想要的,我相信您只需将响应设置为vCard MIME类型之一(
text/x-vCard
text/directory;profile=vCard
,或
text/directory

我希望这有帮助

-编辑-

使用以下代码,系统会正确提示我在Internet Explorer中打开或保存(并在Outlook中打开文件)。不幸的是,Chrome似乎仍然不支持打开文件,所以似乎有一个下载框是永久性的。在IE中尝试以下代码,你就会明白我的意思;它起作用了。另外,顺便说一下,如果格式正确的话,我可以更轻松地复制代码。你有没有可能编辑你的帖子,突出显示代码,点击“101010”图标?非常感谢,祝你好运

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();
        }
    }
}

是的,你完全明白我的问题。但我用了这些哑剧,但没有用。你能告诉或向别人要这个吗?拜托。我只是想避免出现“运行或下载对话框”。并希望(通过c#代码)将内置设置为生成的.vcf文件作为outlook。@Lalit:重新阅读您的评论后,看起来您想做一些您不能做的事情。有时候你不能强制执行任何东西(谷歌浏览器),而在你可以的时候,浏览器仍然有发言权;不是服务器(服务器只能提出建议,MIME类型的设置就是这样)。
Response.ContentType = "text/x-vcard";
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();
        }
    }
}