public static void Hello(this _Inspector inspector) { var mailItem = (MailItem)inspector.CurrentItem; var names = mailItem.Recipients.Cast <Recipient>() .Where(_ => _.Type == (int)OlMailRecipientType.olTo) .Select(_ => { _.AddressEntry.TryGetGreetingName(out var name); return(name); }) .Where(_ => _ != null); var greeting = String.Format(@"Hallo {0}, text Freundliche Grüße, Andreas " , names.Join(", ")); dynamic editor = inspector.WordEditor; dynamic selection = editor.Windows[1].Selection; selection.Delete(); selection.InsertAfter(greeting); }
private IntPtr GetHandle(_Inspector inspector) { Guid oleInterface = new Guid("00000114-0000-0000-C000-000000000046"); IntPtr handle = IntPtr.Zero; IntPtr punk = Marshal.GetIUnknownForObject(inspector); IntPtr inspectorInterface; Marshal.QueryInterface(punk, ref oleInterface, out inspectorInterface); try { IOleWindow window = (IOleWindow) Marshal.GetTypedObjectForIUnknown(inspectorInterface, typeof(IOleWindow)); if (window != null) { window.GetWindow(out handle); } } catch (COMException ex) { Logger.LogError(ex); } finally { Marshal.Release(inspectorInterface); } return handle; }
public void TestOrganizerRoundTrip() { var eventData = @" BEGIN:VCALENDAR PRODID:-//Inverse inc./SOGo 2.2.16//EN VERSION:2.0 BEGIN:VTIMEZONE TZID:Europe/Vienna X-LIC-LOCATION:Europe/Vienna BEGIN:DAYLIGHT TZOFFSETFROM:+0100 TZOFFSETTO:+0200 TZNAME:CEST DTSTART:19700329T020000 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 TZOFFSETTO:+0100 TZNAME:CET DTSTART:19701025T030000 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU END:STANDARD END:VTIMEZONE BEGIN:VEVENT UID:59E2-55170300-17-5DFC2102 SUMMARY:testmeeting LOCATION:daheim DESCRIPTION:important meeting 1 CLASS:PUBLIC PRIORITY:1 CREATED:20150328T194007Z DTSTAMP:20150328T194007Z LAST-MODIFIED:20150328T194140Z DTSTART;TZID=Europe/Vienna:20150429T110000 DTEND;TZID=Europe/Vienna:20150429T123000 TRANSP:OPAQUE X-SOGO-SEND-APPOINTMENT-NOTIFICATIONS:NO ORGANIZER;CN=Test Account:mailto:[email protected] ATTENDEE;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT;CN=Alexander Nimmervoll:mailto:[email protected] ATTENDEE;PARTSTAT=TENTATIVE;ROLE=REQ-PARTICIPANT;CN=Testaccount OBS2009:mailto:[email protected] END:VEVENT END:VCALENDAR "; var evt = OutlookTestContext.DeserializeICalendar(eventData); using (var outlookEvent = OutlookTestContext.CreateNewAppointment()) { OutlookTestContext.EntityMapper.Map2To1(evt, outlookEvent); _Inspector inspector = outlookEvent.Inner.GetInspector; inspector.Activate(); ManualAssert.Assert("Check if the Organizer of the Meeting is Equal to: 'Test Account <*****@*****.**>'"); inspector.Close(OlInspectorClose.olDiscard); var newCalendar = OutlookTestContext.EntityMapper.Map1To2(outlookEvent, new iCalendar()); Assert.That(newCalendar.Events[0].Organizer.CommonName, Is.EqualTo("Test Account")); Assert.That(newCalendar.Events[0].Organizer.Value.ToString(), Is.EqualTo("mailto:[email protected]")); outlookEvent.Inner.Delete(); } }