You can get the message ID using below API:
GET /me/messages
GET /users/{id | userPrincipalName}/messages
You can get the attachment ID using below API's:
GET /groups/{id}/threads/{id}/posts/{id}/attachments
GET /groups/{id}/conversations/{id}/threads/{id}/posts/{id}/attachments
Ref Doc:
https://learn.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/post-list-attachments?view=graph-rest-1.0&tabs=http
Thanks,
Nivedipa
If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.