Python graph html body

WVGO 1 Reputation point
2022-12-27T19:14:16.847+00:00

Hi

I'm trying to send emails using graph API in python. I'm sending the body as HTML when I post the request the html body that I send is not in the proper format what I see in the browser. Style is not applying to the html content.

Please find the attachment for the code reference.

Thank you,274358-python-email.txt

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bhanu Kiran 3,616 Reputation points
    2022-12-28T00:20:16.323+00:00

    Hello @WVGO ,

    I am able to successfully send mail in HTML format, Please refer to the below body:

    {  
        "message": {  
            "body": {  
                "content": "The group represents <b>Nevada.</b>",  
                "contentType": "HTML"  
            },  
            "sender": {  
                "emailAddress": {  
                    "address": "******@domain.com",  
                    "name": "user"  
                }  
            },  
            "subject": "Meet for lunch?",  
            "toRecipients": [  
                {  
                    "emailAddress": {  
                        "address": " ******@domain.com",  
                        "name": "user"  
                    }  
                }  
            ]  
        }  
    }  
    

    274432-sendmail.png

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.