1

We have a shared Office365 mailbox and I’m trying to write some Python code using MSGraph to identify emails which have been responded to.

In Outlook, if you attempt to reply to a message that has already been replied to then a message will pop up at the top of the email stating : “You are not responding to the latest message in this conversation. Click here to open it.” This is what I am attempting to mimic in my code.

I am able to list folders and emails quite happily, but I cannot work out how to identify conversations.

I have found a Microsoft post “List Conversations” https://learn.microsoft.com/en-us/graph/api/group-list-conversations?view=graph-rest-1.0&tabs=python From which I have extracted this line

result = await graph_client.groups.by_group_id('group-id').conversations.get()

which returns

msgraph.generated.models.o_data_errors.o_data_error.ODataError: APIError Code: 404 message: None error: MainError(additional_data={}, code='ErrorInvalidGroup', details=None, inner_error=None, message="The requested group 'group-id' is invalid.", target=None)

Which makes sense, as I have no idea what to enter for the group-id so I’ve just left in the literal text ‘group-id' from the original.

I don’t understand how groups are associated with an email conversation. Is anyone able to enlighten me as to what group-id I should be entering here, how I can find that id, and how groups are associated with email conversations.

1
  • I took a quick look at the API docs and there is a List Groups operation, learn.microsoft.com/en-us/graph/api/…. From that, you may need to choose one of the groups to list its associated conversations. Commented Jun 6 at 15:36

1 Answer 1

0
def get_group_id_by_email(access_token, group_email):
    """Get the group ID using the group's email address"""
    headers = {
        'Authorization': f'Bearer {access_token}',
        'Content-Type': 'application/json'
    }
    
    # Filter groups by email address
    endpoint = f"https://graph.microsoft.com/v1.0/groups?$filter=mail eq '{group_email}'"
    response = requests.get(endpoint, headers=headers)
    
    if response.status_code == 200:
        groups = response.json().get('value', [])
        if groups:
            return groups[0].get('id')
    
    return None

try this, you'll need to pass in your access token of course

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.