none
EWS 2010 Managed API Cannot delete email if scheduled via extended properties RRS feed

  • Question

  • I  have code that schedules an email as below:

    Scheduling Code:

     _ExchangeService.Credentials = new WebCredentials(_UserName, _Encrypt.getEncryptedValue(),_Domain);
    _ExchangeService.AutodiscoverUrl("somemailbox@somedomain.com");
       
                
                this.ScheduleRequest = bAddScheduling;

      try
                    {
                        EmailMessage message = new EmailMessage(_ExchangeService);

        //set message properties

       //add scheduling     

         message.SetExtendedProperty(PR_DEFERRED_SEND_TIME, ut);

                message.SetExtendedProperty(PR_DEFERRED_DELIVERY_TIME, ut);

    if(bAddScheduling)

    {  

      message.Save(WellKnownFolderName.Outbox);

    }

    message.SendAndSaveCopy();

    }

    Delete Code:

        ItemId id = new ItemId(ID);

                EmailMessage current =  EmailMessage.Bind(_ExchangeService, id);

                try

                {
                    
                    current.Delete(DeleteMode.HardDelete);
                }
                catch (Exception e)
                {
                    throw e;
                    //string ex = e.ToString();
                    //_COMPlusExceptionCode = -532462766
                    //[Microsoft.Exchange.WebServices.Data.ServiceResponseException] = {"Object cannot be deleted."}

                }
            }

    Scheduling seems to be working just fine.  My problem is that I want to enable the deletion of a scheduled email and when I try to delete I receive "Microsoft.Exchange.WebServices.Data.ServiceResponseException: Object cannot be deleted."  If I just save the email and do not send it I can delete it programatically.  If I make a call to Send or SendAndSaveCopy after saving the message I always receive the object cannot be deleted message.  I can log into the mailbox as the service account and delete it just fine.  I am stumped please help.  

    Monday, May 21, 2012 6:54 PM

All replies

  • I am having this exact issue.  Does anyone from the exchange team at MSFT have any guidance on this matter?  This thread has remained unanswered for 3 months.

    Thanks in advance.

    Tuesday, August 26, 2014 8:25 PM