Value cannot be null. Parameter name: storeId

-- -- 872 Reputation points
2024-03-27T23:27:45.15+00:00

Hi

When I use below code to send email usisng a graph client;

await graphClient.Users[SenderUserEmail].SendMail(message, true).Request().PostAsync();

I get exception;

Code: ErrorInternalServerError Message: An internal server error occurred. The operation failed., Value cannot be null. Parameter name: storeId

How can I fix this please?

Thanks

Regads

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Yakun Huang 80 Reputation points
    2024-03-28T09:07:50.5766667+00:00

    Hi @-- --

    This problem occurs due to the lack of corresponding parameters when sending the request, if you want to use the graph client to send an email, you can send it according to the code below.

    await graphClient.Users[SenderUserEmail].SendMail.PostAsync(requestBody);
    

    Here you need to add the argument from the SendMain method to the requestBody object and use it as a parameter to the PostAsync method.

    Screenshot 2024-03-28 170529

    If you want to know more detailed information, you can check out this link:

    https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=csharp

    Hope this helps.

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

    0 comments No comments