MS graph API - How can I send the generated events as a message ?

Brass Contributor

I want to make an online meeting event and send a message to the channel.

I made an online meeting event and checked that all mail and notifications work properly.
The important thing is that I want to send the event as a message to the channel.

 

When I create event,

var @event = new Event
                {
                    
                    Subject = subject,
                    Body = new ItemBody
                    {
                        ContentType = BodyType.Html,
                        Content = subject
                    },
                    Start = new DateTimeTimeZone
                    {
                        DateTime = "2020-09-22T14:30:00",
                        TimeZone = "Korea Standard Time"
                    },
                    End = new DateTimeTimeZone
                    {
                        DateTime = "2020-09-22T14:35:00",
                        TimeZone = "Korea Standard Time"
                    },
                    Organizer = new Recipient()
                    {
                        EmailAddress = new EmailAddress
                        {
                            Address = groupInfo.Mail,
                            Name = groupInfo.DisplayName
                        }
                    }
                    ,
                    Attendees = new List<Attendee>()
                    {
                        new Attendee
                        {
                            EmailAddress = new EmailAddress
                            {
                                Address = ownMail,
                                Name = "name",
                            },
                            Type = AttendeeType.Required,
                            Status = new ResponseStatus
                            {
                                Response = ResponseType.Accepted
                            }
                        }
                         , new Attendee
                         {
                             EmailAddress = new EmailAddress
                             {
                                 Address = groupInfo.Mail,
                                 Name = groupInfo.DisplayName
                             },
                             Type = AttendeeType.Required
                             
                         }
                    },
                    AllowNewTimeProposals = true,
                    IsOnlineMeeting = true,
                    OnlineMeetingProvider = OnlineMeetingProviderType.TeamsForBusiness,
                    IsOrganizer = false,
                    ResponseStatus = new ResponseStatus()
                    {
                        Response = ResponseType.Organizer
                    }

                };

                result2 = await graphClient.Groups[pGroupId].Events
                    .Request()
                    .Header("Prefer", "outlook.timezone=\"Korea Standard Time\"")
                    .AddAsync(@event);

 

For now, i'm sending back an online meeting url as a message at channel.

 

like this,

 var chatMessage = new ChatMessage
                {
                    Subject = result2.Subject,
                    Body = new ItemBody
                    {
                        ContentType = result2.Body.ContentType,
                        Content = result2.Body.Content
                    }
                    
                };

                await graphClient.Teams[pGroupId].Channels[channel.Id].Messages
                    .Request()
                    .AddAsync(chatMessage);

                

 

I tried this doc, but my events don't have attachments.

Please let me know if you have a way.
I've been looking all day, but I don't know. Thank you for any help.

1 Reply

@BoHyun , You can use channel emaild in the attendeeslist so that you can post your event to your channel.