Get Images from outlook calendar event details.

Copper Contributor

Hi All,

I have a requirement to get the calendar event details and show them on the SharePoint page.

I'm able to get the calendar event details such as start date, end date, and event title using graph API.
But I can't get the image details from the description field.

KalimuthuAyyadurai_1-1677752777223.png

 

KalimuthuAyyadurai_0-1677752417074.png
Kindly help me with this issue.

Thanks

 

1 Reply
Get the calendar event using Graph API. You can use the GET /me/events/{id} endpoint to retrieve the event details.

Check if the event has a description field. If it does, retrieve the value of the description field.

Parse the description field value to extract the image details. You can use regular expressions or HTML parsing libraries like Beautiful Soup or lxml to extract the image details from the HTML content.

Once you have extracted the image details, you can display the image on the SharePoint page using an appropriate method such as an image control or an HTML img tag.

# Check if the event has a description field
if 'body' in event and 'content' in event['body']:
# Extract the image details from the description field
description = event['body']['content']
match = re.search(r'<img.*?src=["\'](\S*?)["\']', description)
if match:
image_url = match.group(1)