DeleteItem¶
This documentation provides details about the DeleteItem class within the pyews
package.
This class is used to delete items (typically mailbox items) from the specified user mailbox.
Deletes items (typically email messages) from a users mailboxes.
Examples:
To use any service class you must provide a UserConfiguration object first.
Like all service classes, you can access formatted properties from the EWS endpoint using the response
property.
If you want to move a single message to the Deleted Items
folder then provide a string value of the message ID.
The default delete_type
is to move a message to the Deleted Items
folder.
userconfig = UserConfiguration(
'first.last@company.com',
'mypassword123'
)
messageId = 'AAMkAGZjOTlkOWExLTM2MDEtNGI3MS04ZDJiLTllNzgwNDQxMThmMABGAAAAAABdQG8UG7qjTKf0wCVbqLyMBwC6DuFzUH4qRojG/OZVoLCfAAAAAAEMAAC6DuFzUH4qRojG/OZVoLCfAAAu4Y9UAAA='
deleteItem = DeleteItem(userconfig).run(message_id)
If you want to HardDelete a single message then provide a string value of the message ID and specify the delete_type
as HardDelete
:
from pyews import UserConfiguration
from pyews import DeleteItem
userconfig = UserConfiguration(
'first.last@company.com',
'mypassword123'
)
messageId = 'AAMkAGZjOTlkOWExLTM2MDEtNGI3MS04ZDJiLTllNzgwNDQxMThmMABGAAAAAABdQG8UG7qjTKf0wCVbqLyMBwC6DuFzUH4qRojG/OZVoLCfAAAAAAEMAAC6DuFzUH4qRojG/OZVoLCfAAAu4Y9UAAA='
deleteItem = DeleteItem(userConfig).run(message_id, delete_type='HardDelete')
- Args:
- messageId (list or str): An email MessageId to delete userconfiguration (UserConfiguration): A UserConfiguration object created using the UserConfiguration class delete_type (str, optional): Defaults to MoveToDeletedItems. Specify the DeleteType. Available options are [‘HardDelete’, ‘SoftDelete’, ‘MoveToDeletedItems’]
- Raises:
- SoapAccessDeniedError: Access is denied when attempting to use Exchange Web Services endpoint SoapResponseHasError: An error occurred when parsing the SOAP response ObjectType: An incorrect object type has been used