Skip to content

Commit

Permalink
Check if GetActiveObject() actually returns anything.
Browse files Browse the repository at this point in the history
  • Loading branch information
phw198 committed Feb 5, 2022
1 parent 9fc14fa commit d540b98
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,8 @@ public static void AttachToOutlook(ref Microsoft.Office.Interop.Outlook.Applicat
log.Info("Attaching to the already running Outlook process.");
try {
oApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
if (oApp == null)
throw new ApplicationException("GetActiveObject() returned NULL without throwing an error.");
} catch (System.Exception ex) {
if (OGCSexception.GetErrorCode(ex) == "0x800401E3") { //MK_E_UNAVAILABLE
log.Warn("Attachment failed - Outlook is running without GUI for programmatic access.");
Expand Down

0 comments on commit d540b98

Please sign in to comment.