从outlook2003 获取contact list, 并添加新的contact

    技术2022-05-11  69

    下篇代码,是我我 的代码里,直接拷出来的, 没有修改,编译, 需要你修改一下才能用。         _Application    m_olApp;        _NameSpace        m_olNS;        _Items            m_Items;        MAPIFolder        m_Folder;        _ContactItem    m_Contact;        m_olApp.CreateDispatch( " Outlook.Application " ,NULL);         m_olNS  =  m_olApp.GetNamespace( " MAPI " );        m_Folder  =  m_olNS.GetDefaultFolder( 10 );     //  or  m_Folder   = m_olNS.PickFolder(); Allow user to select the folder         m_Items  =  m_Folder.GetItems();         //          //  get the first record         //         m_Contact         =  m_Items.GetFirst();         while (m_Contact  !=  NULL  &&  m_Contact.GetClass()  !=   40 )         {            m_Contact        = m_Items.GetNext();        }          //          //  get the next record         //         m_Contact         =  m_Items.GetNext();         while (m_Contact  !=  NULL  &&  m_Contact.GetClass()  !=   40 )         {            m_Contact        = m_Items.GetNext();        }          // you can get the email info you want          m_Contact.GetEmail1DisplayName();         // create new record item         _ContactItem  m_curNewItem  =   m_olApp.CreateItem( 2 );                 //          // set new record info         //         m_curNewItem.SetLastName();        m_curNewItem.SetHomeTelephoneNumber(strValue);                 //  TH         m_curNewItem.SetHome2TelephoneNumber(strValue);             //  Th         m_curNewItem.SetBusinessTelephoneNumber(strValue);             //  TO         m_curNewItem.SetBusiness2TelephoneNumber(strValue);         //  To         m_curNewItem.SetMobileTelephoneNumber(strValue);             //  TM         m_curNewItem.SetPagerNumber(strValue);                         //  TP         m_curNewItem.SetBusinessFaxNumber(strValue);                 //  TF         m_curNewItem.SetHomeFaxNumber(strValue);                     //  Tf         m_curNewItem.SetEmail1Address(strValue);                     //  TE         m_curNewItem.SetEmail2Address(strValue);                     //  Te         m_curNewItem.SetWebPage(strValue);                             //  TU         m_curNewItem.SetHomeAddress(strValue);                         //  TS         m_curNewItem.SetBirthday(bdDate);         //  save info         m_curNewItem.Save();        m_olApp.Quit();        m_olApp.ReleaseDispatch(); 用代码之前, 还有把outlook 的类型库, 引入道你的工程里,才能编译成功。 outlooK 和 outlook express 根本不同。

    最新回复(0)