Adding an appointment to a non-default calendar linked to iCloud











up vote
0
down vote

favorite












I am attempting to add new appointments to a calendar linked using "iCloud for Windows". I have read everything I can find on the subject of Outlook and Calendars on this site and I have used OutlookSpy to navigate through the various objects and folders, (and I thank Dimitry for the huge help he has provided the coding community for this fabulous tool).



However, I am still unable to write to the non-default calendar.



Based on this answer, Creating an appointment to a specific calendar. VBA outlook, here is my code...



using Microsoft.Office.Interop.Outlook
...
Application app = new Application();
AppointmentItem appt = null;

app.ActiveExplorer().CurrentFolder =
app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
Recipient recipent = app.Session.CreateRecipient("Jobs");

appt = app.CreateItem(OlItemType.olAppointmentItem);
appt.Subject = "Subject goes here ...";
appt.Location = "Address/Suburb/State";
appt.Body = "Job GPS: " + "-1234567 987654";
appt.Start = DateTime.Now;
appt.End = appt.Start.AddHours(2);

app.ActiveExplorer().CurrentFolder.Items.Add(appt); <--- Fails here


I am uncertain whether it is the fact that the calendar I am wanting to write to is a non-Outlook calendar, or if I simply am missing something prior to attempting to save the appointment.



Any assistance will be greatly appreciated.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I am attempting to add new appointments to a calendar linked using "iCloud for Windows". I have read everything I can find on the subject of Outlook and Calendars on this site and I have used OutlookSpy to navigate through the various objects and folders, (and I thank Dimitry for the huge help he has provided the coding community for this fabulous tool).



    However, I am still unable to write to the non-default calendar.



    Based on this answer, Creating an appointment to a specific calendar. VBA outlook, here is my code...



    using Microsoft.Office.Interop.Outlook
    ...
    Application app = new Application();
    AppointmentItem appt = null;

    app.ActiveExplorer().CurrentFolder =
    app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
    Recipient recipent = app.Session.CreateRecipient("Jobs");

    appt = app.CreateItem(OlItemType.olAppointmentItem);
    appt.Subject = "Subject goes here ...";
    appt.Location = "Address/Suburb/State";
    appt.Body = "Job GPS: " + "-1234567 987654";
    appt.Start = DateTime.Now;
    appt.End = appt.Start.AddHours(2);

    app.ActiveExplorer().CurrentFolder.Items.Add(appt); <--- Fails here


    I am uncertain whether it is the fact that the calendar I am wanting to write to is a non-Outlook calendar, or if I simply am missing something prior to attempting to save the appointment.



    Any assistance will be greatly appreciated.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am attempting to add new appointments to a calendar linked using "iCloud for Windows". I have read everything I can find on the subject of Outlook and Calendars on this site and I have used OutlookSpy to navigate through the various objects and folders, (and I thank Dimitry for the huge help he has provided the coding community for this fabulous tool).



      However, I am still unable to write to the non-default calendar.



      Based on this answer, Creating an appointment to a specific calendar. VBA outlook, here is my code...



      using Microsoft.Office.Interop.Outlook
      ...
      Application app = new Application();
      AppointmentItem appt = null;

      app.ActiveExplorer().CurrentFolder =
      app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
      Recipient recipent = app.Session.CreateRecipient("Jobs");

      appt = app.CreateItem(OlItemType.olAppointmentItem);
      appt.Subject = "Subject goes here ...";
      appt.Location = "Address/Suburb/State";
      appt.Body = "Job GPS: " + "-1234567 987654";
      appt.Start = DateTime.Now;
      appt.End = appt.Start.AddHours(2);

      app.ActiveExplorer().CurrentFolder.Items.Add(appt); <--- Fails here


      I am uncertain whether it is the fact that the calendar I am wanting to write to is a non-Outlook calendar, or if I simply am missing something prior to attempting to save the appointment.



      Any assistance will be greatly appreciated.










      share|improve this question













      I am attempting to add new appointments to a calendar linked using "iCloud for Windows". I have read everything I can find on the subject of Outlook and Calendars on this site and I have used OutlookSpy to navigate through the various objects and folders, (and I thank Dimitry for the huge help he has provided the coding community for this fabulous tool).



      However, I am still unable to write to the non-default calendar.



      Based on this answer, Creating an appointment to a specific calendar. VBA outlook, here is my code...



      using Microsoft.Office.Interop.Outlook
      ...
      Application app = new Application();
      AppointmentItem appt = null;

      app.ActiveExplorer().CurrentFolder =
      app.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
      Recipient recipent = app.Session.CreateRecipient("Jobs");

      appt = app.CreateItem(OlItemType.olAppointmentItem);
      appt.Subject = "Subject goes here ...";
      appt.Location = "Address/Suburb/State";
      appt.Body = "Job GPS: " + "-1234567 987654";
      appt.Start = DateTime.Now;
      appt.End = appt.Start.AddHours(2);

      app.ActiveExplorer().CurrentFolder.Items.Add(appt); <--- Fails here


      I am uncertain whether it is the fact that the calendar I am wanting to write to is a non-Outlook calendar, or if I simply am missing something prior to attempting to save the appointment.



      Any assistance will be greatly appreciated.







      c# outlook calendar






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 11:28









      MarkChimes

      5916




      5916
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          MAPIFolder.Items.Add only takes a string (message class) or one of the OlItemType enums (e.g. OlItemType.olAppointmentItem = 1)



          You need to use Namespace.GetSharedDefaultFolder instead of GetDefaultFolder, which you only use to reset the actively selected fodler in OUtlook (why?).






          share|improve this answer





















          • My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
            – MarkChimes
            Nov 19 at 20:06












          • You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
            – Dmitry Streblechenko
            Nov 19 at 23:17










          • Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
            – MarkChimes
            Nov 20 at 0:57










          • GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
            – Dmitry Streblechenko
            Nov 20 at 1:01










          • My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
            – MarkChimes
            Nov 20 at 1:23











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373670%2fadding-an-appointment-to-a-non-default-calendar-linked-to-icloud%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          MAPIFolder.Items.Add only takes a string (message class) or one of the OlItemType enums (e.g. OlItemType.olAppointmentItem = 1)



          You need to use Namespace.GetSharedDefaultFolder instead of GetDefaultFolder, which you only use to reset the actively selected fodler in OUtlook (why?).






          share|improve this answer





















          • My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
            – MarkChimes
            Nov 19 at 20:06












          • You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
            – Dmitry Streblechenko
            Nov 19 at 23:17










          • Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
            – MarkChimes
            Nov 20 at 0:57










          • GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
            – Dmitry Streblechenko
            Nov 20 at 1:01










          • My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
            – MarkChimes
            Nov 20 at 1:23















          up vote
          0
          down vote













          MAPIFolder.Items.Add only takes a string (message class) or one of the OlItemType enums (e.g. OlItemType.olAppointmentItem = 1)



          You need to use Namespace.GetSharedDefaultFolder instead of GetDefaultFolder, which you only use to reset the actively selected fodler in OUtlook (why?).






          share|improve this answer





















          • My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
            – MarkChimes
            Nov 19 at 20:06












          • You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
            – Dmitry Streblechenko
            Nov 19 at 23:17










          • Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
            – MarkChimes
            Nov 20 at 0:57










          • GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
            – Dmitry Streblechenko
            Nov 20 at 1:01










          • My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
            – MarkChimes
            Nov 20 at 1:23













          up vote
          0
          down vote










          up vote
          0
          down vote









          MAPIFolder.Items.Add only takes a string (message class) or one of the OlItemType enums (e.g. OlItemType.olAppointmentItem = 1)



          You need to use Namespace.GetSharedDefaultFolder instead of GetDefaultFolder, which you only use to reset the actively selected fodler in OUtlook (why?).






          share|improve this answer












          MAPIFolder.Items.Add only takes a string (message class) or one of the OlItemType enums (e.g. OlItemType.olAppointmentItem = 1)



          You need to use Namespace.GetSharedDefaultFolder instead of GetDefaultFolder, which you only use to reset the actively selected fodler in OUtlook (why?).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 17:08









          Dmitry Streblechenko

          41.8k32760




          41.8k32760












          • My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
            – MarkChimes
            Nov 19 at 20:06












          • You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
            – Dmitry Streblechenko
            Nov 19 at 23:17










          • Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
            – MarkChimes
            Nov 20 at 0:57










          • GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
            – Dmitry Streblechenko
            Nov 20 at 1:01










          • My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
            – MarkChimes
            Nov 20 at 1:23


















          • My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
            – MarkChimes
            Nov 19 at 20:06












          • You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
            – Dmitry Streblechenko
            Nov 19 at 23:17










          • Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
            – MarkChimes
            Nov 20 at 0:57










          • GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
            – Dmitry Streblechenko
            Nov 20 at 1:01










          • My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
            – MarkChimes
            Nov 20 at 1:23
















          My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
          – MarkChimes
          Nov 19 at 20:06






          My thinking was to select the "Jobs" calendar inside the iCloud object, make it the default folder, and then add an appointment to it. Namespace("MAPI").GetSharedDefaultFolder requires a recipient and my code now errors on this command. Furthermore, now, I am unsure whether Recipient should be "iCloud", or "Jobs".
          – MarkChimes
          Nov 19 at 20:06














          You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
          – Dmitry Streblechenko
          Nov 19 at 23:17




          You should be something that can uniquely be resolved to that mailbox owner. If it is not an Exchange mailbox, then use Namespace.Stores to get the parent store of that folder, then call Store.GetDefaultFolder(olFolderCalendar)
          – Dmitry Streblechenko
          Nov 19 at 23:17












          Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
          – MarkChimes
          Nov 20 at 0:57




          Is there a difference between GetSharedDefaultFolder and a folder that is shared and not a default folder? My Outlook configuration includes 3 mailboxes, one of which has 2 additional aliases, plus an "iCal for Windows" calendar-only link to an Apple user's calendar. It is this last calendar that I need to insert appointments into. From your last comment, is it correct for me to think that I need to identify the store where this calendar is located first, and then get the default (shared) folder?
          – MarkChimes
          Nov 20 at 0:57












          GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
          – Dmitry Streblechenko
          Nov 20 at 1:01




          GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
          – Dmitry Streblechenko
          Nov 20 at 1:01












          My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
          – MarkChimes
          Nov 20 at 1:23




          My apologies Dmitry, I should have mentioned at the very beginning. We are using Office 365 (but Outlook is locally installed on each PC).
          – MarkChimes
          Nov 20 at 1:23


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373670%2fadding-an-appointment-to-a-non-default-calendar-linked-to-icloud%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Tonle Sap (See)

          I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

          Guatemaltekische Davis-Cup-Mannschaft