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.
c# outlook calendar
add a comment |
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.
c# outlook calendar
add a comment |
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.
c# outlook calendar
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
c# outlook calendar
asked 2 days ago
MarkChimes
5916
5916
add a comment |
add a comment |
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?).
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
|
show 10 more comments
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?).
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
|
show 10 more comments
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?).
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
|
show 10 more comments
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?).
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?).
answered 2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
|
show 10 more comments
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
GetSharedDefaultFolder is Exchange-only. It does not sound like you are using Exchange.
– Dmitry Streblechenko
2 days ago
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
2 days ago
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
2 days ago
|
show 10 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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