等以后有时间了在写内容
直接贴代码,呵呵
环境 vs.net 2008 C#
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using Microsoft.WindowsMobile.PocketOutlook;
- //==========================================================================================
- //
- // EricContacts
- // Copyright (C) 2008-2010, 杭州市电力局 Eric
- //
- // 作该demo的目的:用了公司某个项目上的一款带手机功能的PDA(MC35 windows mobile 6.0)
- // 项目作完以后要上交,但是联系人里有我的300多个联系人,因为只能一个一个删除,
- // 如果这样删除的话,不等删除完,我就人就挂了,故此,写一个小demo,批量删除contact
- //
- // 运行本程序,点击删除,将直接删除您PDA联系人中的所有联系人,对此带来的一切后果
- // 本人不负任何责任,请慎重使用
- //
- //
- //==========================================================================================
- namespace EricContacts
- {
- public partial class MainForm : Form
- {
- OutlookSession MyoutlookSession;
- public MainForm()
- {
- InitializeComponent();
- MyoutlookSession = new OutlookSession();
- refreshContacts();
- }
- //刷新联系人列表
- private void refreshContacts()
- {
- lstContacts.Items.Clear();
- try
- {
- foreach(Contact c in MyoutlookSession.Contacts.Items)
- {
- ListViewItem item = new ListViewItem(
- new string[] {
- c.FileAs,
- c.MobileTelephoneNumber,
- c.HomeTelephoneNumber,
- c.BusinessTelephoneNumber,
- c.Email1Address}
- );
- //将联系人一个一个的添加到lstContacts列表
- lstContacts.Items.Add(item);
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(String.Format("出错: {0}", ex.Message),"刷新",MessageBoxButtons.OK,MessageBoxIcon.Hand,MessageBoxDefaultButton.Button1);
- }
- }
- private void menuItemDelete_Click(object sender, EventArgs e)
- {
- MyoutlookSession.Contacts.Items.Clear();
- refreshContacts();
- MessageBox.Show("删除成功","提示消息:",MessageBoxButtons.OK,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
- }
- private void menuItemExit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
demo 下载地址
http://d.download.youkuaiyun.com/down/676910/EricLiang