Rocky Smolin
rockysmolin at bchacc.com
Tue Mar 9 16:20:58 CST 2010
Thanks for that Max. I'll try it but it looks pretty bulletproof.
Do you have something like that for deleting all the appointments within a
data range?
TIA
Rocky
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Tuesday, March 09, 2010 12:40 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Picking Alternate Calendar
Rocky:
Here is the code:
Max
Private Sub sCalendar()
Dim ol As Outlook.Application
Dim onMAPI As NameSpace
Dim ofMyOutlook As MAPIFolder
Dim ofFolder As MAPIFolder
Dim ofCalendar As MAPIFolder
Dim myItem As Object
Dim myCalendar As Object
Dim strCalendarName As String
Dim myRequiredAttendee As Outlook.Recipient
Dim myoptionalAttendee As Outlook.Recipient
Dim myResourceAttendee As Outlook.Recipient
' this is the variable which can be passed in as the name of the new
(non-default calendar)
' because it is non-system calendar we cannot use ol.creatitem() but
have to use .items.add
strCalendarName = "My Calendar"
Set ol = New Outlook.Application
Dim ifor As Integer
Set onMAPI = ol.GetNamespace("MAPI")
Set ofMyOutlook = onMAPI.Folders("Max Outlook") ' normally "Personal
Folders" but I renamed mine
Set ofCalendar = ofMyOutlook.Folders("Calendar") ' this is the normal
name
' go though the folders inside the calendar folder and see if we can
find the user-defined calendar
For ifor = 1 To ofCalendar.Folders.Count
' Debug.Print ofCalendar.Folders(ifor), ifor
If ofCalendar.Folders(ifor) = strCalendarName Then
Set myCalendar = ofCalendar.Folders(ifor) ' Got it
ifor = ofCalendar.Folders.Count ' jump out
End If
Next ifor
If ifor > ofCalendar.Folders.Count + 1 Then
MsgBox "Check the name of the user caledar as it does not appear as
a sub folder of Calendar"
Exit Sub
End If
' might need ClickYes installed if you require to send without user
viewing first.
With myCalendar
Set myItem = myCalendar.Items.Add '
ol.CreateItem(olAppointmentItem)
With myItem
.MeetingStatus = olMeeting
.Subject = "Meeting Tomorrow BoardRoom - test from Max at
AccessD"
.Location = "Conference Room No. 33"
.Start = #3/10/2010 1:30:00 PM# ' month/day/year - change as
required.
.Duration = 90
'
Set myRequiredAttendee =
myItem.Recipients.Add("rockysmolin at bchacc.com")
myRequiredAttendee.Type = olRequired
Set myoptionalAttendee =
myItem.Recipients.Add("rockysmolin at bchacc.com")
myoptionalAttendee.Type = olOptional
Set myResourceAttendee =
myItem.Recipients.Add("rockysmolin at bchacc.com")
myResourceAttendee.Type = olResource
.Display
'myItem.Send
End With
End With
End Sub
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.733 / Virus Database: 270.14.129/2605 - Release Date: 03/08/10
23:33:00