返回首页

我已经成功地添加新的联系人到Outlook。
现在,我要添加新的联系人从Outlook数据库在C#在web应用程序。
它是如何可能?

(下面是代码添加新的联系人到Outlook。)
但我想从Outlook中添加。
代码是: -

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.IO;

using System.Data.SqlClient;

using System.Web.Configuration;

using OutlookInterop = Microsoft.Office.Interop.Outlook;

 

public partial class ContactPersonalDetail : System.Web.UI.Page

{

   

    SqlConnection cnn = new SqlConnection(ConfigurationSettings.AppSettings["con"]);

    private string uploadDirectory;

   

    OutlookInterop.ApplicationClass app = new OutlookInterop.ApplicationClass();

     public bool CheckCustomFolderExisits()

     {

        

        OutlookInterop.NameSpace ns = app.GetNamespace("MAPI");

        OutlookInterop.MAPIFolder contactsFolder = app.ActiveExplorer().Session.GetDefaultFolder(OutlookInterop.OlDefaultFolders.olFolderContacts);

        foreach (OutlookInterop.MAPIFolder subFolder in contactsFolder.Folders)

        {

            if (subFolder.Name == "MAPI")

            {

                return true;

            }

            else

                return false;

        }

        return false;

     }

    

  

    protected void Page_Load(object sender, EventArgs e)

    {

        

    }

 protected void lnkSaveasoutlook_Click(object sender, EventArgs e)

    {

        try

        {

            OutlookInterop.ContactItem newContact = (OutlookInterop.ContactItem)app.CreateItem(OutlookInterop.OlItemType.olContactItem);

            //    if (newContact.Display(true))

            //    {

            newContact.FirstName = (txtfirstname.Text);

            newContact.LastName = (txtlastname.Text);

            newContact.Email1Address = (txtemail.Text);

            newContact.WebPage = (txtwebpage.Text);

           

            newContact.Display(true);

            //newContact.Save();

            //}

         

          

            

        }

        catch (Exception ex)

        {

            Response.Write(ex.ToString());

        }

        

    }

}

回答

评论会员: 时间:2