我已经看过并尝试了这里和其他网站的各种答案,而下面的代码工作-它只是不会在"Winder_Related"中创建约会。压延机。这是第二个,即"2"。在默认的"日历"下的日历,我也试过使用那个引用。
注意,我使用一个Outlook .pst文件和3个电子邮件帐户,我看过其他解决方案,但他们指的是使用非默认的电子邮件地址/帐户,.pst文件。我不需要这些约会的收件人电子邮件地址
我只有3个日历,默认文件夹和2个子文件夹日历(默认)旅行日程表Winder_Related
下面是当前的代码,它可以工作,但仍然在默认日历
中创建它
Sub Create_Appt_For_WinderJob()
ActiveSheet.Cells(ActiveCell.Row, 1).Select
'This is meant to use "Winder_Related" folder, the 2nd sub folder under the deafault Calendar
'however it still goes to default calendar
Dim OutApp As Outlook.Application
Dim nmsNameSpace As Outlook.Namespace
Dim fldCalendar As Outlook.MAPIFolder
Dim OutAppoint As Outlook.AppointmentItem
Dim ItemsCal As Outlook.items
Dim SC As Range
Set OutApp = Outlook.Application
Set nmsNameSpace = OutApp.GetNamespace("MAPI")
'this is supposed to work, but the default is still used
Set fldCalendar = nmsNameSpace.GetDefaultFolder(olFolderCalendar).Folders("Winder_Related")
'This next line uses the correct folder ID but still the default is used
'Set fldCalendar = nmsNameSpace.GetFolderFromID("00000000B119696562A6BB4588F5F089C4B07208625E5F00")
Set OutAppoint = OutApp.CreateItem(olAppointmentItem)
Set SC = ActiveCell
'**have not included multiple lines of code after here as it just collects info from various cells on the current row
'and then uses this to populate appointment fields - it works fine**
Chees Brian "Decoboy"``
CreateItem方法创建并返回一个新的Microsoft Outlook项目。创建的项目将保存到Drafts
文件夹(用于电子邮件)或任何默认文件夹(日历)。在这种情况下,如果您想将其保存到任何其他默认值,则需要显式调用Move
方法。
如果你需要在一个特定的文件夹中创建一个新项目,你需要使用Items
类的Add
方法来代替:
Set OutApp = Outlook.Application
Set nmsNameSpace = OutApp.GetNamespace("MAPI")
Set fldCalendar = nmsNameSpace.GetDefaultFolder(olFolderCalendar).Folders("Winder_Related")
Set OutAppoint = fldCalendar.Items.Add(olAppointmentItem)
您可以在我为技术博客写的文章中阅读更多相关内容:
- 如何:创建新的Outlook约会项 如何以编程方式创建和显示新的Outlook邮件项目:c#, VB。净