windows mobile 5.0批量删除contact联系人

 

等以后有时间了在写内容

直接贴代码,呵呵

 

环境 vs.net 2008 C#

 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using Microsoft.WindowsMobile.PocketOutlook;
  9. //==========================================================================================
  10. //
  11. //      EricContacts
  12. //      Copyright (C) 2008-2010, 杭州市电力局 Eric
  13. //
  14. //      作该demo的目的:用了公司某个项目上的一款带手机功能的PDA(MC35 windows mobile 6.0)
  15. //      项目作完以后要上交,但是联系人里有我的300多个联系人,因为只能一个一个删除,
  16. //      如果这样删除的话,不等删除完,我就人就挂了,故此,写一个小demo,批量删除contact
  17. //
  18. //      运行本程序,点击删除,将直接删除您PDA联系人中的所有联系人,对此带来的一切后果
  19. //      本人不负任何责任,请慎重使用
  20. //
  21. //
  22. //==========================================================================================
  23. namespace EricContacts
  24. {
  25.     public partial class MainForm : Form
  26.     {
  27.         OutlookSession MyoutlookSession;
  28.         public MainForm()
  29.         {
  30.             InitializeComponent();
  31.             MyoutlookSession = new OutlookSession();
  32.             refreshContacts();
  33.             
  34.         }
  35.         //刷新联系人列表
  36.         private void refreshContacts()
  37.         {
  38.             lstContacts.Items.Clear();
  39.             try
  40.             {
  41.                 foreach(Contact c in MyoutlookSession.Contacts.Items)
  42.                 {
  43.                     ListViewItem item = new ListViewItem(
  44.                         new string[] {
  45.                             c.FileAs,
  46.                             c.MobileTelephoneNumber,
  47.                             c.HomeTelephoneNumber,
  48.                             c.BusinessTelephoneNumber,
  49.                             c.Email1Address}
  50.                             );
  51.                     //将联系人一个一个的添加到lstContacts列表
  52.                     lstContacts.Items.Add(item);
  53.                 }
  54.             }
  55.             catch(Exception ex)
  56.             {
  57.                 MessageBox.Show(String.Format("出错: {0}", ex.Message),"刷新",MessageBoxButtons.OK,MessageBoxIcon.Hand,MessageBoxDefaultButton.Button1);
  58.             }
  59.         }              
  60.         private void menuItemDelete_Click(object sender, EventArgs e)
  61.         {
  62.             MyoutlookSession.Contacts.Items.Clear();
  63.             refreshContacts();
  64.             MessageBox.Show("删除成功","提示消息:",MessageBoxButtons.OK,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
  65.         }
  66.         private void menuItemExit_Click(object sender, EventArgs e)
  67.         {
  68.             Application.Exit();
  69.         }
  70.         
  71.     }
  72. }

demo 下载地址

 

http://d.download.csdn.net/down/676910/EricLiang 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值