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

 下篇代码,是我我 的代码里,直接拷出来的, 没有修改,编译, 需要你修改一下才能用。


        _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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值