这是基于我在网上找到的一个例子,在默认邮箱中创建通讯组列表时有效。它适用于为默认文件夹创建通讯组列表,但不适用于默认邮箱以外的任何邮箱。
Dim oNameSpace As Outlook.NameSpace
Dim oRecipient As Outlook.Recipient
Set oNameSpace = Application.GetNamespace("MAPI")
Set oRecipient = oNameSpace.CreateRecipient("Some Person")
oRecipient.Resolve
If oRecipient.Resolved Then
Set oItem = Application.CreateItem(olDistributionListItem)
Set oRecipient = Application.Session.CreateRecipient("Some User")
oRecipient.Resolve
If oRecipient.Resolved Then
oItem.AddMember oRecipient
'Add note to list and display
oItem.DLName = "Northwest -------------------"
objItem.Body = "Regional Sales Manager - NorthWest"
oItem.Save
End If
End If
我希望能够选择将在下面的代码中创建通讯组列表的邮箱将提示用户确认在创建通讯组列表时打开了正确的联系人窗口
Dim oParent As Object
Set oParent = Application.ActiveExplorer.CurrentFolder.Parent
Resp = MsgBox("Acting on Account: " & oParent & vbCrLf & vbCrLf & "OK to Continue, Cancel to Quit", vbOKCancel)
If Resp = vbCancel Then
End
End If
问题是解决以下两行
我确实审查了所有建议的问题并测试了那些看起来很有希望但没有成功的问题
而不是使用
Application.CreateItem
,使用MAPIFolder.Items.Add
,其中MAPIFolder
需要来自默认商店以外的Outlook商店。
尝试以下更改:
Dim oStore As Outlook.Store
Dim oFolder As Outlook.MAPIFolder
Set oStore = Application.ActiveExplorer.CurrentFolder.Store
set oFolder = Store.GetDefaultFolder(olFolderContacts)
Set oItem = oFolder.Items.Add("IPM.DistList")