Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 2904|回复: 1
打印 上一主题 下一主题

求救!关于c# find microsoft outlook contact

[复制链接]

17

主题

0

好友

316

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

跳转到指定楼层
1#
发表于 2010-12-22 03:16 AM |只看该作者 |倒序浏览
string Filter = string.Format("[FullName]='{0}'", PFullName);

OutlookInterop.ContactItem contact = subFolder2.Items.Find(string.Format(Filter)) as OutlookInterop.ContactItem;

这个行不通,还有别的方法吗?还是我写错了?




收藏收藏0

2

主题

0

好友

251

积分

支柱会员

Rank: 4Rank: 4Rank: 4Rank: 4

2#
发表于 2010-12-22 10:37 PM |只看该作者
Google MSDN

  1. using System;
  2. using System.Reflection; // to use Missing.Value
  3. //TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.
  4. //using Outlook = Microsoft.Office.Interop.Outlook;

  5. namespace ReadContact
  6. {
  7.    public class Class1
  8.    {
  9.       public static int Main(string[] args)
  10.       {       
  11.          try
  12.          {
  13.             // Create the Outlook application.
  14.             Outlook.Application oApp = new Outlook.Application();

  15.             // Get the NameSpace information.
  16.             Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

  17.             // Log on by using a dialog box to choose the profile.
  18.             oNS.Logon(Missing.Value, Missing.Value, true, true);

  19.             // Alternate logon method that uses a specific profile.
  20.             // TODO: If you use this logon method,
  21.             //  change the profile name to an appropriate value.
  22.             //oNS.Logon("YourValidProfile", Missing.Value, false, true);
  23.   
  24.             // Get the default Contacts folder.
  25.             Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

  26.             // Get the Items collection from the folder.
  27.             Outlook.Items oItems = (Outlook.Items)oContacts.Items;

  28.             // Get the first contact item in the Items collection.
  29.             Outlook.ContactItem oCt = (Outlook.ContactItem)oItems.GetFirst();

  30.             // Output some common properties.
  31.             Console.WriteLine(oCt.FullName);
  32.             Console.WriteLine(oCt.Title);
  33.             Console.WriteLine(oCt.Birthday);
  34.             Console.WriteLine(oCt.CompanyName);
  35.             Console.WriteLine(oCt.Department);
  36.             Console.WriteLine(oCt.Body);
  37.             Console.WriteLine(oCt.FileAs);
  38.             Console.WriteLine(oCt.Email1Address);
  39.             Console.WriteLine(oCt.BusinessHomePage);
  40.             Console.WriteLine(oCt.MailingAddress);
  41.             Console.WriteLine(oCt.BusinessAddress);
  42.             Console.WriteLine(oCt.OfficeLocation);
  43.             Console.WriteLine(oCt.Subject);
  44.             Console.WriteLine(oCt.JobTitle);

  45.             // Display the contact.
  46.             oCt.Display(true);

  47.             // Log off.
  48.             oNS.Logoff();

  49.             // Explicitly release objects.
  50.             oCt = null;
  51.             oItems = null;
  52.             oContacts = null;
  53.             oNS = null;
  54.             oApp = null;
  55.          }

  56.          //Simple error handling.
  57.          catch (Exception e)
  58.          {
  59.             Console.WriteLine("{0} Exception caught.", e);
  60.          }  

  61.          //Default return value.
  62.          return 0;
  63.       }       
  64.    }
  65. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-26 02:36 AM , Processed in 0.169118 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部