Skip to content

'Cannot read property 'constructor' of undefined' when trying to send draft email #225

Closed
@vemundeldegard

Description

@vemundeldegard

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

Description

When I am trying to send a draft message, I get a TypeError.

Console Errors:

TypeError: Cannot read property 'constructor' of undefined
    at Object.exports.serializeContent (/Users/v/platform-email/node_modules/@microsoft/microsoft-graph-client/src/GraphRequestUtil.ts:44:36)
    at GraphRequest.<anonymous> (/Users/v/platform-email/node_modules/@microsoft/microsoft-graph-client/src/GraphRequest.ts:552:10)
    at step (/Users/v/platform-email/node_modules/tslib/tslib.js:136:27)
    at Object.next (/Users/v/platform-email/node_modules/tslib/tslib.js:117:57)
    at /Users/v/platform-email/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/v/platform-email/node_modules/tslib/tslib.js:106:16)
    at GraphRequest.post (/Users/v/platform-email/node_modules/@microsoft/microsoft-graph-client/lib/src/GraphRequest.js:468:24)
    at post (/Users/v/platform-email/server/resolvers/email/draft/send.js:63:14)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Steps to Reproduce

  1. Create message and get a messageID:
const message = {
        subject:"Did you see last night's game?",
        importance:"Low",
        body:{
            contentType:"HTML",
            content:"They were <b>awesome</b>!"
        },
        toRecipients:[
            {
                emailAddress:{
                    address:"[email protected]"
                }
            }
        ]
    };

    let response = await client.api(`/me/messages`)
        .post(message);
  1. Then try to send the draft message you just created.
client.api(`/me/messages/${messageId}/send`)
            .post().then(data => console.log(data)).catch(err => console.log(err)) 

Expected behavior:

The message should be sent. It works if I use the send a mail without creating a draft like the following. But I need to save the draft to get access to the messageId to be stored for later.

const message = {
            "message": {
            subject:"Did you see last night's game?",
            importance:"Low",
            body:{
                contentType:"HTML",
                content:"They were <b>awesome</b>!"
            },
            toRecipients:[
                {
                    emailAddress:{
                        address:"[email protected]"
                    }
                }
            ]
        }
        };
          
        client.api('/me/sendMail')
              .post(message).then(data => console.log(data)).catch(err => console.log(err))

Actual behavior:

I get the error.

Usage Information

SDK Version - 2.0.0

  • Node (Check, if using Node version of SDK)

Node Version - v10.16.3

  • Browser (Check, if using Browser version of SDK)

Browser Name - [The name of Browser that you are using for SDK]

Version - [The version of the browser you are using]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions