Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 注释';Odata.context';没有得到承认_C#_Email_Microsoft Graph Api_Odata - Fatal编程技术网

C# 注释';Odata.context';没有得到承认

C# 注释';Odata.context';没有得到承认,c#,email,microsoft-graph-api,odata,C#,Email,Microsoft Graph Api,Odata,通过Microsoft Graph Api访问电子邮件,我已向Message对象添加了单值属性。但是在执行SendMail查询时:client.Users[MailBoxId].SendMail(message,true.Request().PostAsync()它正在抛出一个错误,状态为-code:RequestBodyRead 消息:找到批注“odata.context”。当前位置无法识别或不需要此批注。 内部错误: 其他数据: 日期:2020-07-24T07:46:37 请求id:xxx

通过Microsoft Graph Api访问电子邮件,我已向Message对象添加了单值属性。但是在执行SendMail查询时:
client.Users[MailBoxId].SendMail(message,true.Request().PostAsync()它正在抛出一个错误,状态为-code:RequestBodyRead
消息:找到批注“odata.context”。当前位置无法识别或不需要此批注。
内部错误:
其他数据:
日期:2020-07-24T07:46:37
请求id:xxxx-xxx-xxx-xxx-xxxxx
客户ID:xxxx-xxx-xxx-xxx-xxxxx。
.

解决这一问题的任何线索都将非常有用。

首先使用AddAsync()创建邮件草稿,然后使用SendMail().PostAsync()发送邮件时遇到类似问题。这导致了以下例外情况: 消息:代码:RequestBodyRead消息:找到批注“odata.context”。当前位置无法识别或不需要此批注

我将SendMail().PostAsync()替换为Send().PostAsync(),问题得到了解决。下面的代码片段

            //Construct the Email Message
            var emailMessage = new Message
            {
                Subject = emailSubject,
                Body = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content = emailBody
                },
                ToRecipients = toEmailList,
                CcRecipients = ccEmailList,
                BccRecipients = bccEmailList,

            };

            //Create a draft message
            var draftEmailMessage = await graphClient.Users[emailId].Messages
                    .Request()
                    .AddAsync(emailMessage);

            //Code to add attachments to the draft message
            ....

            //Send the email message
            // NOTE: This does NOT work, throws Odata.context error 
            /*
            await graphClient.Users[emailId].SendMail(draftEmailMessage, true)
                .Request()
                .PostAsync();
            */
            // NOTE: Replaced above commented code with this - works perfectly!
            await graphClient.Users[emailId].Messages[draftEmailMessage.Id].Send()
                .Request()
                .PostAsync();

首先使用AddAsync()创建草稿邮件,然后使用SendMail()发送邮件时遇到类似问题。PostAsync()。这导致了以下例外情况: 消息:代码:RequestBodyRead消息:找到批注“odata.context”。当前位置无法识别或不需要此批注

我将SendMail().PostAsync()替换为Send().PostAsync(),问题得到了解决。下面的代码片段

            //Construct the Email Message
            var emailMessage = new Message
            {
                Subject = emailSubject,
                Body = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content = emailBody
                },
                ToRecipients = toEmailList,
                CcRecipients = ccEmailList,
                BccRecipients = bccEmailList,

            };

            //Create a draft message
            var draftEmailMessage = await graphClient.Users[emailId].Messages
                    .Request()
                    .AddAsync(emailMessage);

            //Code to add attachments to the draft message
            ....

            //Send the email message
            // NOTE: This does NOT work, throws Odata.context error 
            /*
            await graphClient.Users[emailId].SendMail(draftEmailMessage, true)
                .Request()
                .PostAsync();
            */
            // NOTE: Replaced above commented code with this - works perfectly!
            await graphClient.Users[emailId].Messages[draftEmailMessage.Id].Send()
                .Request()
                .PostAsync();