try { // Create new Session Outlook.Application outApp = new Microsoft.Office.Interop. Outlook.Application(); Outlook.NameSpace ns = outApp.GetNamespace("MAPI"); ns.Logon(Type.Missing, Type.Missing, false, true); // Change Context Outlook.Recipient organizer = ns.CreateRecipient( "shared@collaboration-2-go.de"); organizer.Resolve(); // Open Shared Calendar Outlook.MAPIFolder folder = ns.GetSharedDefaultFolder( organizer, Microsoft.Office.Interop.Outlook.OlDefaultFolders. olFolderCalendar); // Create Meeting Request in Shared Folder Outlook._AppointmentItem mr = (Outlook._AppointmentItem)folder.Items.Add( Microsoft.Office.Interop.Outlook. OlItemType.olAppointmentItem); mr.MeetingStatus = Microsoft.Office.Interop.Outlook. OlMeetingStatus.olMeeting; mr.Location = "my location"; Outlook.Recipient recipient = mr.Recipients.Add( "user@collaboration-2-go.de"); recipient.Resolve(); recipient.Type = (int)Outlook.OlMeetingRecipientType.olRequired; mr.Subject = "my subject"; mr.Start = DateTime.Now.AddHours(1); mr.Duration = 60; mr.Body = "my meeting request"; mr.ReminderMinutesBeforeStart = 15; mr.ReminderSet = true; mr.Save(); mr.Send(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); }
$FolderPath = "/TEMP" $NewFolder = "CalendarTest" $PFRoot = "file://./backofficestorage/litwareinc.com/Public Folders" # Use PowerShell cmdlet to create new folder # (depending upon whether a root folder or not) if ($FolderPath -ne "") { $f = $FolderPath -replace("/", "\") New-PublicFolder -Name $NewFolder -Path $f } else { New-PublicFolder -Name $NewFolder } # Use ADO to change the folder type $o=New-Object -comobject ADODB.Record $updated=$false $timeout=60 while (($updated -eq $false) -and ($timeout -gt 0)) { $o.Open($PFRoot + $FolderPath + "/" + $NewFolder, "", 3, -1, -1, "", "") foreach($item in $o.Fields) { if($item.Name -eq "http://schemas.microsoft.com/exchange/outlookfolderclass") { $updated=$true $item.Value="IPF.Appointment" } } $o.Fields.Update() $o.Close() if ($updated -eq $false) { Start-Sleep -s 1 $timeout -- } }