Reputation: 35
how to send a email using office 365 API in c#.net?can anyone provide a sample code. I tried with Office 365 Exchange Web serivce and its worked.
Upvotes: 0
Views: 4459
Reputation: 879
It is not clear if you are looking for samples using SDK or raw HTTP requests. Samples for sending mail using raw HTTP requests in C# are here and here. Below is sample code snippet to send mail using the sdk:
GraphServiceClient client = new GraphServiceClient(<UseYourAuthProvider>);
Message message = new Message
{
Subject="Hello",
Body=new ItemBody{Content="World",ContentType=BodyType.Text},
ToRecipients=new []{new Recipient{EmailAddress=new EmailAddress{Address="[email protected]"}}}
};
var request = client.Me.SendMail(message, true);
await request.Request().PostAsync();
A complete sample using the sdk is available here (Note: it is not related to sending mail, but should give you reference to sdk usage in general)
Upvotes: 4