web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Send Email using .NetCore Odata with queue as sender

(0) ShareShare
ReportReport
Posted on by 745

Hi All,

    i have been developing an integration with Dyanmics CRM  through webAPI in .NetCore 

   i have been doing all operations using ODATA queries so

   I need to send Email using shared Mailbox/queues using this ODATA services

  can anybody knows how to send it or with some sample Code

Thanks 

I have the same question (0)
  • Verified answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    You can create email entity record and then use SendEmail action to send that email.

    Now you will need to define your Send and Receipient in your email object.

    Please see below blog which will guide you on the object construct.

    vblogs.in/.../

    and if you are looking for sample web api code for c# then check below docs page-

    docs.microsoft.com/.../web-api-samples-csharp

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    MMK Profile Picture
    745 on at

    Hi Bipin,

      Thanks your reply helped me out

       i was having issues setting from and To fields and calling the send action in .NetCore

      here is code for any body in >netCore

    public static async Task<dynamic> PostMethod(dynamic Obj, string apiname)

           {

               try

               {

                   var token = GetToken();

                   var httpClient = new HttpClient

                   {

                       BaseAddress = new Uri(resource +"api/data/v9.1/"),

                       Timeout = new TimeSpan(0, 2, 0)

                   };

                   httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");

                   httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0");

                   httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                   httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                   httpClient.DefaultRequestHeaders.Add("Prefer", "return=representation");

                   // Add this line for TLS complaience

                   ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

                   try

                   {

                       //+ "?$select=" + parameter

                       HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, apiname)

                       {

                           Content = new StringContent(Obj.ToString(), Encoding.UTF8, "application/json")

                       };

                       var res = await httpClient.SendAsync(request);

                       if (res.IsSuccessStatusCode)

                       {

                           var jRetrieveResponse = JObject.Parse(res.Content.ReadAsStringAsync().Result);

                           dynamic coll  = JsonConvert.DeserializeObject(jRetrieveResponse.ToString());

                           return coll ;

                       }

                       else

                       {

                           throw new Exception();

                       }

                   }

                   catch (Exception ex)

                   {

                       throw ex;

                   }

               }

               catch (Exception ex)

               {

                   throw ex;

               }

           }

     public async Task SendEmail(string contactid,string QueueId, string emailContent)

           {

               try

               {

                   JObject data = JObject.Parse(@"  

                                       {

                                           'description': '" + emailContent + @"',  

                                           'regardingobjectid_contact@odata.bind':  '/contacts('" +contactid+ @"')',

                                           'subject': 'Test Email Creation',

                                           'email_activity_parties': [

                                               {

                                                   'partyid_queue@odata.bind': '/queues('" + QueueId + @"')',

                                                   'participationtypemask': 1  

                                               },

                                               {

                                                   'partyid_contact@odata.bind': '/contacts('" + contactid + @"')',

                                                   'participationtypemask': 2

                                               }

                                           ]

                                       }");

                   dynamic newEmailContact = await SV.PostMethod(data, "emails");

                   var activityid = newEmailContact.activityid;

                   string apiname = "emails("+Convert.ToString(activityid)+")/Microsoft.Dynamics.CRM.SendEmail";

                   JObject EmailContact = new JObject { };

                   EmailContact["IssueSend"] = true;

                   dynamic ress= await SV.PostMethod(EmailContact, apiname);

               }

               catch (Exception ex)

               {

               }

           }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 176 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 139

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans