保存联系后创建约会
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了保存联系后创建约会相关的知识,希望对你有一定的参考价值。
我正在编写一个宏来创建联系人后创建一个约会。
用户可以单击按钮,输入联系人的详细信息,一旦保存,就应该打开一个新的约会窗口。
问题是在保存联系人之前调用约会子。因此,不存在要传递给子的对象/联系人。
我的代码:
' Application-level variables
Public objOL As Outlook.Application
Public objNS As Outlook.NameSpace
' Public Folders
Public objPublicFolderRoot As Outlook.Folder
Public objCompanyFolder As Outlook.Folder
Public objContactFolder As Outlook.Folder
Public objCalFolder As Outlook.Folder
' Set the Public Folders
Set objPublicFolderRoot = objNS.GetDefaultFolder(olPublicFoldersAllPublicFolders) Set objCompanyFolder = objPublicFolderRoot.Folders("Company_Shared") Set objContactFolder = objCompanyFolder.Folders("Contacts") Set objCalFolder = objCompanyFolder.Folders("Calendars")
Sub CreateEmptyContact()
Dim objContact As Outlook.ContactItem
Set objNS = Application.GetNamespace("MAPI")
' Build out the contact item
Set objContact = objContactFolder.Items.Add(olContactItem)
With objContact
.Display
End With
CreateAppointment(objContact)
' Reset vars
Set objContact = Nothing
Set objPublicFolderRoot = Nothing
Set objCompanyFolder = Nothing
Set objContactFolder = Nothing
End Sub
Public Sub CreateAppointment(objContact As Outlook.ContactItem)
' Create the appointment on the public folder calendar with the passed contact Public Sub CreateAppointment(objContact As Outlook.ContactItem)
Dim objCalAppt As Outlook.AppointmentItem
Set objCalAppt = Application.CreateItem(olAppointmentItem)
' Add to the Appointment to the existing Calendar items
Set objCalAppt = objCalFolder.Items.Add(olAppointmentItem)
With objCalAppt
.MeetingStatus = olNonMeeting 'Not an invitation
.Start = Now
.Duration = 120
.Save
.Display
End With
' Reset vars
Set objCalAppt = Nothing
End Sub
什么是我最好的方法前进。例如,我应该在Contact_Send或Contact_AfterWrite上使用类似WithEvents的东西吗?
答案
您可以以模态方式显示联系人(.Display(true)
),也可以在“联系人”文件夹中查看Items.ItemAdd
事件以触发(保存联系人后)并使用传递给事件处理程序的项目。
以上是关于保存联系后创建约会的主要内容,如果未能解决你的问题,请参考以下文章