1

I am looking to use the source code of an email which has the desired template that i need in the Microsoft Graph API.

The standard format for this looks like so:

    "message": {
        "subject": "Meet for lunch?",
        "body": {
            "contentType": "HTML",
            "content": "The new cafeteria is open."
        },

The sourcecodes template that i am looking to use already has contentType etc within the code.I have tried removing contentType and content and just having the source code within the body but this still does not work. Below is start of the source code that i am looking to use:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:v="urn:schemas-microsoft-com:vml"
    xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if !mso]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="http://www.opusenergy.com/wp-content/uploads/2016/03/Favicon-150x150.png" />
<title>Opus</title>
<!--[if (gte mso 9)|(IE)]>
        <style type="text/css">
            table {border-collapse: collapse !important;}
        </style>

Any help will be greatly appreciated, Thank you.

DomF
  • 13
  • 5
  • The above payload is not what Graph API looks for. You need to specify the payload for the create message API call and the structure is given in the Graph API document. Still if you want to customize, you can do it, by make sure to modify/customize in-lines with Microsoft Graph API recommendation. Say i will put the HTML content inside the content of the Graph API call, specify the contenttype as HTML. This is the way i would start testing it make sure whether it's working or still i need to modify so that the message can show correctly in Outlook or not. – Dev Dec 14 '20 at 13:03
  • Thank you for your response. I have structured it following the guidlines and it works sending html code, but using a template for the body with CSS inside of it does not. Also the documentation on the API does not cover this. Thanks – DomF Dec 14 '20 at 15:40
  • Glad to hear that it works and you tried as i updated above. If i want to send out email/template then i would first make sure it works in Word/Outlook; so that you can validate the HTML/CSS tags are working in, as i know that not all tags are not supported. Please keep this best practice and plan it accordingly. It will help you to build the template as you wish and you're guaranteed that the Outlook will show-up them as well. – Dev Dec 14 '20 at 17:48
  • If you dont have any further questions, let me move this to answer? So it can be useful to the community as well. – Dev Dec 14 '20 at 17:49
  • Moving this to answer. Consider upvoting and accepting it as answer. So it will be useful to others in the community as well. – Dev Dec 15 '20 at 14:07
  • any luck passing HTML as the content? – Francesco Pegoraro Sep 15 '21 at 15:28

1 Answers1

0
  • The above payload is not what Graph API looks for. You need to specify the payload for the create message API call and the structure is given in the Graph API document. Still if you want to customize, you can do it, by making sure to modify/customize in-lines with Microsoft Graph API recommendation. Say i will put the HTML content inside the content of the Graph API call, specify the contenttype as HTML. This is the way i would start testing it make sure whether it's working or still i need to modify so that the message can show correctly in Outlook or not.
  • You tried the above recommendation and confirmed that it works.
  • If i want to send out email/template then i would first make sure it works in Word/Outlook; so that you can validate the HTML/CSS tags are working in, as i know that not all tags are not supported. Please keep this best practice and plan it accordingly. It will help you to build the template as you wish and you're guaranteed that the Outlook will show-up them as well.
Dev
  • 2,428
  • 2
  • 14
  • 15
  • Thanks for the response again...When you say make sure it works in Word/Outlook could you elaborate on that please? Because the template is just the source code of an already successfull email, and i am just changing words around in the text which will go out to a customer. So the HTML/CSS should all be fine, its just figuring out how the Microsoft Graph API will accept the source code and if it needs to be broken down. Thanks again – DomF Dec 16 '20 at 16:58
  • Ok let me clarify - If its a successful email and all tags are working, then you're good. But if you're in plans of creating new template then consider this - Say, if you created a template with HTML/CSS, copy that in Word/Outlook, make sure it shows correctly; when you notice any of the CSS/HTML tags not showing, then ignore/replace with the related ones. – Dev Dec 16 '20 at 18:58
  • how to check html/css in word/outlook – Flame alchemist Jun 09 '22 at 14:00