在 Outlook 中取消删除联系人

发布于 2024-08-24 23:12:11 字数 724 浏览 10 评论 0原文

我有一个用 Delphi 编写的应用程序,可以在 Outlook 中添加/更新联系人。我遇到的问题是,如果联系人已在 Outlook 中删除,代码仍会找到该联系人并进行更新 - 并且该联系人仍保持删除状态。有没有办法确定联系人是否已删除或取消删除联系人?

代码大致如下:

  OutlookApp := CreateOleObject('Outlook.Application');
  Mapi := OutlookApp.GetNameSpace('MAPI');

//.....
        try
          if ContactOutlookEntryID.AsString <> '' then
            aContact := Mapi.GetItemFromID(ContactOutlookEntryID.AsString);
        except
        end;
          //try to locate the contact if they have been synchro'd before
        if VarIsEmpty(aContact) then //if not found
          aContact := Contacts.Items.Add(2); //add a new contact to outlook
        aContact.LastName := ContactSurname.AsString;
//.....

I have an application written in Delphi that adds / updates contacts in outlook. The problem I'm having is that if the contact has been deleted in Outlook, the code still finds the contact and updates it - and the contact still remains deleted. Is there a way I can determine if the contact is deleted or undelete the contact?

Roughly the code looks something like:

  OutlookApp := CreateOleObject('Outlook.Application');
  Mapi := OutlookApp.GetNameSpace('MAPI');

//.....
        try
          if ContactOutlookEntryID.AsString <> '' then
            aContact := Mapi.GetItemFromID(ContactOutlookEntryID.AsString);
        except
        end;
          //try to locate the contact if they have been synchro'd before
        if VarIsEmpty(aContact) then //if not found
          aContact := Contacts.Items.Add(2); //add a new contact to outlook
        aContact.LastName := ContactSurname.AsString;
//.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朱染 2024-08-31 23:12:11

删除联系人后,它们会被放入“已删除邮件”文件夹中。除了位于该文件夹中之外,没有其他“已删除”状态。 “取消删除”就像将其移回一样简单。

ContactItem 对象上有一个 Move 方法,您可以使用它来将其移回默认联系人文件夹,您可以通过 NameSpace.GetDefaultFolder 方法。

编辑
要确定联系人是否位于已删除项目文件夹中,您可以查看 Parent 属性,该属性应返回 MAPIFolder 对象。然后,您可以将其 EntryID 与 GetDefaultFolder(olFolderDeletedItems) 返回的 EntryID 进行比较。

When contacts are deleted they are put in the Deleted Items folder. There is no other "deleted" state other than being in that folder. "Undeleting" is as simple as moving it back out.

There is a Move method on the ContactItem object that you can use to move it back to the default contact folder which you can get with the NameSpace.GetDefaultFolder method.

EDIT
To determine if the contact is in the deleted items folder you can look at the Parent property which should return a MAPIFolder object. You can then compare its EntryID against the one returned by GetDefaultFolder(olFolderDeletedItems).

萧瑟寒风 2024-08-31 23:12:11

请记住,这是特定于 PST 的 - 当项目移动到不同的文件夹时,PST 提供程序不会更改条目 ID。

德米特里·斯特雷布莱琴科 (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook,CDO
和 MAPI 开发工具

Keep in mind that this is PST specific - the PST provider does not change the entry id when items are moved to different folders.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文