下面代码测试通过,XP+2003 Sub Appointment() 'Creates an appointment in a year for each month on the 10th working day Dim appolApp As Outlook.Application Dim olApptItem As Outlook.AppointmentItem 'Creates an instance of the application Set appolApp = Outlook.Application 'Creates appointment item j = 1 For i = 8 To 12 Set olApptItem = appolApp.CreateItem(olAppointmentItem) With olApptItem Do Until j = 10 If Weekday(DateSerial(2008, i, j + k), vbMonday) = 6 Or Weekday(DateSerial(2008, i, j + k), vbMonday) = 7 Then k = k + 1 Else j = j + 1 End If Loop .Start = DateSerial(2008, i, j + k) + TimeValue("10:00:00") .End = .Start + TimeValue("01:00:00") .Body = "Please meet with me regarding important issue" .Recipients.Add ("Alan") .Subject = "Meeting with Alan" 'Display the appointment '.Display '这句是显示,如果不需要可注释掉 ' .Send '这句是发送,被我注释掉 .Save k = 0 j = 1 End With Set olApptItem = Nothing Next Set appolApp = Nothing End Sub 随便弄了个删除的, Sub Del_Appointment() 'Creates an appointment in a year for each month on the 10th working day Dim appolApp As Outlook.Application Dim Myns As NameSpace Dim olApptItem As Outlook.AppointmentItem 'Creates an instance of the application Set appolApp = Outlook.Application Set Myns = appolApp.GetNamespace("MAPI") For Each olApptItem In Myns.GetDefaultFolder(olFolderCalendar).Items 'Debug.Print olApptItem.Subject If olApptItem.Subject = "Meeting with Alan" Then olApptItem.Delete Next Set appolApp = Nothing Set Myns = Nothing End Sub
[此贴子已经被作者于2008-8-5 9:52:45编辑过] |