Advertisement
Guest User

Untitled

a guest
Apr 12th, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires -version 2.0
  2.  
  3. # https://blogs.technet.microsoft.com/heyscriptingguy/2009/12/17/hey-scripting-guy-can-i-share-my-microsoft-outlook-calendar-via-e-mail/
  4. # https://msdn.microsoft.com/en-us/library/bb208062.aspx
  5. # https://msdn.microsoft.com/en-us/library/bb208061(v=office.12).aspx
  6. # https://cjoprey.wordpress.com/archived/getting-another-user%E2%80%99s-outlook-folder%E2%80%A6/
  7.  
  8. Add-Type -AssemblyName microsoft.office.interop.outlook
  9. $olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
  10. $olCalendarDetail = "Microsoft.Office.Interop.Outlook.olCalendarDetail" -as [type]
  11. $olCalendarMailFormat = "Microsoft.Office.Interop.Outlook.olCalendarMailFormat" -as [type]
  12. $outlook = New-Object -ComObject outlook.application
  13. $Namespace     = $outlook.GetNamespace("MAPI")
  14. $PublicFolder  = $Namespace.Folders.Item("THISFOLDERISTOPLEVELANDENCLOSESNEXTONEDOWN")
  15. $PublicFolders = $PublicFolder.Folders.Item("ENCLOSINGFOLDEROFPUBLICCALENDAR")
  16. $folder   = $PublicFolders.Folders.Item("PUBLICCALENDAR")
  17. $CalendarSharing=$folder.GetCalendarExporter()
  18.  
  19. # make the below olFreeBusyAndSubject or olFreeBusyOnly if you want
  20. $CalendarSharing.CalendarDetail = $olCalendarDetail::olFreeBusyAndSubject
  21.  
  22. $CalendarSharing.startDate = Get-Date
  23.  
  24. # change this to (Get-Date).addDays(7) if you want more than one day
  25. $CalendarSharing.endDate = Get-Date
  26.  
  27. $CalendarSharing.RestrictToWorkingHours = $false
  28. $CalendarSharing.IncludeAttachments = $false
  29. $CalendarSharing.IncludePrivateDetails = $false
  30.  
  31. # make the below olCalendarMailFormat::olCalendarMailFormatDailySchedule if you want
  32. $MailItem = $CalendarSharing.ForwardAsICal($olCalendarMailFormat::olCalendarMailFormatEventList)
  33.  
  34. $MailItem.DeleteAfterSubmit = $true
  35.  
  36. # configure recipient
  37. $MailItem.Recipients.Add("EMAILADDRESSYOUWANTITMAILEDTO")
  38.  
  39. $MailItem.Send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement