David Lee in Quora.com has written a VBScript on how to send email summary of Outlook calendar. With minor adjustment to the code I am able to make it read non-default calendars (so basically in Outlook 2010, under My Calendars section I have added one more calendar called 'Test Calendar' and I want the scrip to send email summary of the 'Test Calendar' rather than my default calendar called 'Calendar'). But now is if I add the lines to read the non default calendar i.e. 'Test Calendar' the date filter does not apply - it sends summary of whole calendar rather than 7 days. I have no experience in VB so I would very grateful if anyone could look at it and see what I need to change to make it work. If you are feeling awfully generous I would also like code added so it only sends email if it finds anything during the specified date range rather than just sending email with no events. The lines I have added to export 'Test Calendar' are in bold and the original line is commented out.
-----
Const olCalendarMailFormatDailySchedule = 1
Const olFreeBusyAndSubject = 1
Const olFullDetails = 2
Const olFolderCalendar = 9
SendAgenda "someone@someone.com", Date, DateAdd("d", 7, Date)
Sub SendAgenda(strAdr, datBeg, datEnd)
Dim olkApp, olkSes, olkCal, olkExp, olkMsg
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = OlkApp.GetNameSpace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkCal = olkSes.GetDefaultFolder(olFolderCalendar)
Set olkCalFolder = olkCal.Folders("Test Calendar")
Set olkExp = olkCalFolder.GetCalendarExporter
'Set olkExp = olkCal.GetCalendarExporter
With olkExp
.CalendarDetail = olFreeBusyAndSubject
.RestrictToWorkingHours = False
.StartDate = datBeg
.EndDate = datEnd
End With
'msgbox "Email Sent"
Set olkMsg = olkExp.ForwardAsICal(olCalendarMailFormatDailySchedule)
With olkMsg
.To = strAdr
.Send
End With
Set olkCal = Nothing
Set olkExp = Nothing
Set olkMsg = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing
End Sub
-----
-----
Const olCalendarMailFormatDailySchedule = 1
Const olFreeBusyAndSubject = 1
Const olFullDetails = 2
Const olFolderCalendar = 9
SendAgenda "someone@someone.com", Date, DateAdd("d", 7, Date)
Sub SendAgenda(strAdr, datBeg, datEnd)
Dim olkApp, olkSes, olkCal, olkExp, olkMsg
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = OlkApp.GetNameSpace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkCal = olkSes.GetDefaultFolder(olFolderCalendar)
Set olkCalFolder = olkCal.Folders("Test Calendar")
Set olkExp = olkCalFolder.GetCalendarExporter
'Set olkExp = olkCal.GetCalendarExporter
With olkExp
.CalendarDetail = olFreeBusyAndSubject
.RestrictToWorkingHours = False
.StartDate = datBeg
.EndDate = datEnd
End With
'msgbox "Email Sent"
Set olkMsg = olkExp.ForwardAsICal(olCalendarMailFormatDailySchedule)
With olkMsg
.To = strAdr
.Send
End With
Set olkCal = Nothing
Set olkExp = Nothing
Set olkMsg = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing
End Sub
-----