Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

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

$
0
0

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.  


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>