Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GetUserRetentionPolicyTags service #910

Open
mnj009 opened this issue May 7, 2021 · 7 comments
Open

Support GetUserRetentionPolicyTags service #910

mnj009 opened this issue May 7, 2021 · 7 comments

Comments

@mnj009
Copy link

mnj009 commented May 7, 2021

Hi Team ,

Could you please help us to read below two attributes/fields of an email
Retention policy
Expires

I have searched in headers , but no luck

Thanks in advance

@ecederstrand
Copy link
Owner

I can’t find any documentation that these fields should be available on an EWS message item. Do you have a link describing these fields?

@ecederstrand
Copy link
Owner

ecederstrand commented May 9, 2021

Ah, ok. The GetUserRetentionPolicyTags service is not yet supported in exchangelib.

I still don't know what Expires refers to here.

@ecederstrand ecederstrand changed the title how to read Retention policy and Expires in Exchangelib ? Support GetUserRetentionPolicyTags service May 9, 2021
@mnj009
Copy link
Author

mnj009 commented May 9, 2021

In EWS , they have named it as retention date
Here is the documentation from EWS

https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.item.retentiondate

@ahalyarekha
Copy link

Hi, I have also similar task needs to be done using the exchangelib in python to get the rentention date.please provide a update on this.

@ecederstrand
Copy link
Owner

I don't have any plans to work on this myself in the near future. Contributions are welcome, as always.

@brenle
Copy link

brenle commented Jun 27, 2022

I know this one is old, but thought I'd update what I did during recent testing. I'm very new to python so, I'm sure there's better ways to do this, but I just followed the same logic for flags referenced here: #85 (comment)

I had to convert the binary (bytes) to a Microsoft system GUID, so used a function referenced here.

class Label(ExtendedProperty):
    property_tag = 0x3019
    property_type = 'Binary'

    def to_guid():
        b = self.value
        return '-'.join(map(bytes.decode, map(
            binascii.hexlify, (b[0:4][::-1], b[4:6][::-1], b[6:8][::-1], b[8:10], b[10:])
        )))

Message.register('label', Label)

for m in account.inbox.all():
    if m.label:
        print("Subject: " + m.subject)
        print("Label: " + m.label.to_guid())

End result:

Subject: Test email with M365 retention label
Label: 37d7071b-7818-4e98-ae3e-56c0dc330119

Which, with the GUID, you can pull back the name using EXO PowerShell:

Get-ComplianceTag 37d7071b-7818-4e98-ae3e-56c0dc330119 | select Name

Name
----
7YearRecord-LastModified

I think the label names are stored/accessible via EWS since EWSEditor can pull them, but that's as far as I got.

I also didn't look at the Expiration date, but based on the EWSEditor references, I think it might be 0x301c as SystemTime property type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants