Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires -version 2.0
- # https://blogs.technet.microsoft.com/heyscriptingguy/2009/12/17/hey-scripting-guy-can-i-share-my-microsoft-outlook-calendar-via-e-mail/
- # https://msdn.microsoft.com/en-us/library/bb208062.aspx
- # https://msdn.microsoft.com/en-us/library/bb208061(v=office.12).aspx
- # https://cjoprey.wordpress.com/archived/getting-another-user%E2%80%99s-outlook-folder%E2%80%A6/
- Add-Type -AssemblyName microsoft.office.interop.outlook
- $olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
- $olCalendarDetail = "Microsoft.Office.Interop.Outlook.olCalendarDetail" -as [type]
- $olCalendarMailFormat = "Microsoft.Office.Interop.Outlook.olCalendarMailFormat" -as [type]
- $outlook = New-Object -ComObject outlook.application
- $Namespace = $outlook.GetNamespace("MAPI")
- $PublicFolder = $Namespace.Folders.Item("THISFOLDERISTOPLEVELANDENCLOSESNEXTONEDOWN")
- $PublicFolders = $PublicFolder.Folders.Item("ENCLOSINGFOLDEROFPUBLICCALENDAR")
- $folder = $PublicFolders.Folders.Item("PUBLICCALENDAR")
- $CalendarSharing=$folder.GetCalendarExporter()
- # make the below olFreeBusyAndSubject or olFreeBusyOnly if you want
- $CalendarSharing.CalendarDetail = $olCalendarDetail::olFreeBusyAndSubject
- $CalendarSharing.startDate = Get-Date
- # change this to (Get-Date).addDays(7) if you want more than one day
- $CalendarSharing.endDate = Get-Date
- $CalendarSharing.RestrictToWorkingHours = $false
- $CalendarSharing.IncludeAttachments = $false
- $CalendarSharing.IncludePrivateDetails = $false
- # make the below olCalendarMailFormat::olCalendarMailFormatDailySchedule if you want
- $MailItem = $CalendarSharing.ForwardAsICal($olCalendarMailFormat::olCalendarMailFormatEventList)
- $MailItem.DeleteAfterSubmit = $true
- # configure recipient
- $MailItem.Recipients.Add("EMAILADDRESSYOUWANTITMAILEDTO")
- $MailItem.Send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement