Outlook 2010 Email weekly calendar summary

Ganesh

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2010
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
-----
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i think its Set olkExp = olkCal.GetCalendarExporter -

The GetCalendarExporter method automatically sets the defaults for the CalendarSharing class to the standard default options used by the Folder object.

if i share calendar manually, the default for a secondary calendar is whole calendar, for the default calendar it's one day.

I don't know if there is a way to avoid it but will look into it tomorrow.
 

Ganesh

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server 2010
Thanks Diane.

At the moment if I let the script use default calendar the date range works but as soon as I add the line to specify 'Test Calendar' it just emails the whole calendar. When I say whole calendar I mean if I had one entry made in 1 May and another is made in 1 Sep, it'll send whole that period summary ignoring the date range today to 7 days in future.

Just copy and past this (for default calendar) and you'll see it works perfectly.

Const olCalendarMailFormatDailySchedule = 0
Const olFreeBusyAndSubject = 1
Const olFullDetails = 2
Const olFolderCalendar = 9

SendAgenda "someone@someone.com", Date, DateAdd("d", 1, 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 olkExp = olkCal.GetCalendarExporter

With olkExp
.CalendarDetail = olFreeBusyAndSubject
'.IncludeAttachments = True
'.IncludePrivateDetails = True
.RestrictToWorkingHours = False
.StartDate = datBeg
.EndDate = datEnd
End With
'msgbox "Email summary 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
 
Top