如何更新非默认邮箱联系人与分发列表?

huangapple go评论79阅读模式
英文:

How can one update non-default mailbox contacts with a distribution list?

问题

Here are the translated parts of your code:

  1. 这是基于我在网上找到的一个示例。它在默认邮箱中创建一个分发列表。
  2. 我想要为除默认邮箱之外的任何邮箱创建一个分发列表。
  3. 我想要选择创建分发列表的邮箱。
  4. 我想要在创建分发列表时提示用户确认正确的联系人窗口已打开。
  5. 如何解决以下两行?
  6. - Set oItem = 需要一些代码在当前选择的窗口中创建分发列表
  7. - Set oRecipient = 需要一些代码在新的分发列表中创建收件人

Please note that code translation can vary depending on specific requirements and context, so you may need to adapt these translations accordingly.

英文:

This is based on an example I found on the web. It creates a distribution list in the default mailbox.

I want to create a distribution list for any mailbox other than the default.

  1. Dim oNameSpace As Outlook.NameSpace
  2. Dim oRecipient As Outlook.Recipient
  3. Set oNameSpace = Application.GetNamespace("MAPI")
  4. Set oRecipient = oNameSpace.CreateRecipient("Some Person")
  5. oRecipient.Resolve
  6. If oRecipient.Resolved Then
  7. Set oItem = Application.CreateItem(olDistributionListItem)
  8. Set oRecipient = Application.Session.CreateRecipient("Some User")
  9. oRecipient.Resolve
  10. If oRecipient.Resolved Then
  11. oItem.AddMember oRecipient
  12. 'Add note to list and display
  13. oItem.DLName = "Northwest -------------------"
  14. objItem.Body = "Regional Sales Manager - NorthWest"
  15. oItem.Save
  16. End If
  17. End If

I want to select the mailbox the distribution list will be created in.
I want to prompt the user to confirm the correct Contacts window is open when creating the distribution list.

  1. Dim oParent As Object
  2. Set oParent = Application.ActiveExplorer.CurrentFolder.Parent
  3. Resp = MsgBox("Acting on Account: " & oParent & vbCrLf & vbCrLf & "OK to Continue, Cancel to Quit", vbOKCancel)
  4. If Resp = vbCancel Then
  5. End
  6. End If

How do I resolve the below two lines?

  • Set oItem = need some code to create the distribution list in the currently selected window
  • Set oRecipient = need some code to create the recipient in the new distribution list

答案1

得分: 0

请使用MAPIFolder.Items.Add而不是Application.CreateItem,其中MAPIFolder需要来自Outlook存储库而不是默认的存储库。

尝试以下更改:

  1. Dim oStore As Outlook.Store
  2. Dim oFolder As Outlook.MAPIFolder
  3. Set oStore = Application.ActiveExplorer.CurrentFolder.Store
  4. Set oFolder = oStore.GetDefaultFolder(olFolderContacts)
  5. Set oItem = oFolder.Items.Add("IPM.DistList")
英文:

Instead of using Application.CreateItem, use MAPIFolder.Items.Add, where MAPIFolder needs to come from the Outlook store other than the default one.

Try the following change:

  1. Dim oStore As Outlook.Store
  2. Dim oFolder As Outlook.MAPIFolder
  3. Set oStore = Application.ActiveExplorer.CurrentFolder.Store
  4. set oFolder = Store.GetDefaultFolder(olFolderContacts)
  5. Set oItem = oFolder.Items.Add("IPM.DistList")

huangapple
  • 本文由 发表于 2023年4月17日 06:49:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030697.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定