The solution to this problem is two-fold.

1) Invites are never sent to the organizer, as it is presumed that the
organizer knows about their own events
2) EVENT_REQUIRED and EVENT_ACCEPTED are static strings defined in
Who.AttendeeType and Who.AttendeeStatus respectively.

These lines:
type.Value = "EVENT_REQUIRED";
status.Value = "EVENT_ACCEPTED";

Should instead be:
 type.Value = Who.AttendeeType.EVENT_REQUIRED
 status.Value = Who.AttendeeStatus.EVENT_ACCEPTED

The following C# code will add an entry with the organizer/attendee
([EMAIL PROTECTED]) and one attendee ([EMAIL PROTECTED]).  Both
attendees should be marked as required and both attendees should be
marked as 'accepted.'  Lastly, if [EMAIL PROTECTED] has e-mail
notifications configured, they should receive a notification of the
event due to the line adding the gCal:sendEventNotifications element to
the entry's ExtensionElements.  Note, [EMAIL PROTECTED] will not
receive a notification as they are the organizer.


    public void AddEntry()
    {

        CalendarService service = new
CalendarService("CalendarSampleApp");
        service.setUserCredentials(this.userName, this.passWord);
        EventQuery query = new EventQuery();
        query.Uri = new Uri(this.calendarURI);
        EventFeed calFeed = service.Query(query);

        EventEntry entry = new EventEntry();
        entry.Title = new AtomTextConstruct(
                        AtomTextConstructElementType.Title,
                        "testing from dotnet");

        When newTime = new When();
        newTime.StartTime = DateTime.Now.AddDays(1);
        newTime.EndTime = DateTime.Now.AddDays(2);
        entry.Times.Add(newTime);

        Who.AttendeeType type = new Who.AttendeeType();
        type.Value = Who.AttendeeType.EVENT_REQUIRED;

        Who.AttendeeStatus status = new Who.AttendeeStatus();
        status.Value = Who.AttendeeStatus.EVENT_ACCEPTED;

        Who attendee1 = new Who();
        attendee1.ValueString = "[EMAIL PROTECTED]";
        attendee1.Attendee_Type = type;
        attendee1.Attendee_Status = status;
        attendee1.Rel = Who.RelType.EVENT_ATTENDEE;
        entry.Participants.Add (attendee1);

        Who attendee2 = new Who();
        attendee2.ValueString = "[EMAIL PROTECTED]";
        attendee2.Attendee_Type = type;
        attendee2.Attendee_Status = status;
        attendee2.Rel = Who.RelType.EVENT_ATTENDEE;
        entry.Participants.Add (attendee2);

        XmlDocument doc = new XmlDocument();
        XmlDocumentFragment fragment = doc.CreateDocumentFragment();
        fragment.InnerXml = "<gCal:sendEventNotifications
xmlns:gCal=\"" +
                                this.calendarns + "\" value=\"true\"/>";
        entry.ExtensionElements.Add(fragment.FirstChild);

        calFeed.Insert(entry);
    }


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
google-calendar-help-dataapi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to