Cannot delete Room Calendar item with exchagelib code

94 views Asked by At

My problem looks weird. Exchange 2010 SP1. Code looks for conflicting record in Room Calendar and suposed to delete it. Code looks like:

#DELEGATE also doesn't work
 roomAccount = Account(primary_smtp_address=room_mailbox, config=config,
                              autodiscover=False, access_type=IMPERSONATION)
 items = roomAccount.calendar.filter(start__gt=now_with_past) 
 for item in items:
     if (start_dt_ews != start_dt_remote or item.subject != remote_record_subject or duration != remote_record_duration):
                            has_conflicts = detect_conflicts(roomAccount, item)
                            if has_conflicts:                            
                                process_conflict(item, 'update_conflict')
                                remove_meeting_data(item, item.organizer)
                                continue                                

def detect_conflicts(roomAccount, item):
    try:
        has_conflicts = False
        if item.conflicting_meeting_count > 0:
            if item.start_dt != item.start:
                has_conflicts = True
        return has_conflicts
    except Exception as e:
        trace_back = traceback.format_exc()
        log_str = "Error in process_service " + str(e) + " " + str(trace_back)
        Logger.error(log_str)
        return False    

def process_conflict(item, category):
    if item.recurrence:
        conflict_notify_and_delete(item, category, True)
    else:
        conflict_notify_and_delete(item, category, False)
        Logger.error(item.subject + " meeting conflict error.")     
        
def conflict_notify_and_delete(item, category, serial):
    send_email(item.organizer, category, (item.subject))
    try:
        if serial:
            item.delete(affected_task_occurrences=ALL_OCCURRENCIES)
            item.save()
        else:               
            # doesn't  work
            item.delete(send_meeting_cancellations=SEND_TO_NONE, 
 affected_task_occurrences=ALL_OCCURRENCIES)            
            # or also doesn't  work
            item.delete()           
            # or raise trash folder absense error.
            item.move_to_trash()

            # or raise trash folder absense error again.
            item.soft_delete()
            
            #abrakadabra atempts with rescheduling and subsequent deletion raise
            # "Set action is invalid for property. (field: FieldURI(field_uri='calendar:StartTimeZone'))"  error            
            item.start = UTC_NOW() + timedelta(days=6000)
            item.save(update_fields=['start'])
            item.delete()

The strangest fact about all this - any of delete() processing simply silent - no errors, no exceptions, everything looks like to be just fine while actually nothing is deleted of modified.. Second strangest fact - sometimes but not every time i'm trying to item.save() after item.delete() , it raise " AttributeError("Folder must be supplied when in save-only mode")", but item may be deleted at once. And may be not :(( This weird things happen only in part of code that process conflicting calendar items. Notconflicting items processing is fine - deleting and modifiying are ok.

Does anybody has any idea, what is going on and how to finally delete conflicting record from Room calendar without canceling a meeting from organizers's calendar - we do not want user to loose his item and information inside it? I've tried to google EWS setiings that can cause such weirdness but with no luck :(

0

There are 0 answers