How to send invitation email when create event on calendar

HR Info 1 Reputation point
2022-02-15T10:29:00.463+00:00

Hi, I use Microsoft graph calendar when Create event by C# coding not send invitation email to attends list .
How can I send invitation email automatic when add event

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

3 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,756 Reputation points Microsoft Vendor
    2022-02-15T17:39:34.037+00:00

    Hi @HR Info ,

    Based on my test, this user-post-events API is successfully able to send mails to attendees after event is created.
    Here is the example I used for my test.

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
      
    var @event = new Event  
    {  
    	Subject = "Let's go for lunch",  
    	Body = new ItemBody  
    	{  
    		ContentType = BodyType.Html,  
    		Content = "Does noon work for you?"  
    	},  
    	Start = new DateTimeTimeZone  
    	{  
    		DateTime = "2017-04-15T12:00:00",  
    		TimeZone = "Pacific Standard Time"  
    	},  
    	End = new DateTimeTimeZone  
    	{  
    		DateTime = "2017-04-15T14:00:00",  
    		TimeZone = "Pacific Standard Time"  
    	},  
    	Location = new Location  
    	{  
    		DisplayName = "Harry's Bar"  
    	},  
    	Attendees = new List<Attendee>()  
    	{  
    		new Attendee  
    		{  
    			EmailAddress = new EmailAddress  
    			{  
    				Address = "samanthab@contoso.onmicrosoft.com",  
    				Name = "Samantha Booth"  
    			},  
    			Type = AttendeeType.Required  
    		}  
    	}  
    };  
      
    await graphClient.Me.Events  
    	.Request()  
    	.Header("Prefer","outlook.timezone=\"Pacific Standard Time\"")  
    	.AddAsync(@event);  
    

    Please share any request body/API/snippet which you used.
    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

  2. HR Info 1 Reputation point
    2022-02-16T14:18:55.147+00:00

    @SrinivasaRaoDarnaMSFT-7657
    I use this Api and add successfully event on calendar but not sent invitation email

      public async Task<bool> AddEvent(string userEmail, string timeZone,
                string subject,
                DateTime start,
                DateTime end,
                List<string> attendees,
                string tenantId,
                string body = null)
            {
                IntializeAuth(tenantId);
    
                // Create a new Event object with required
                // values
                var newEvent = new Event
                {
                    Subject = subject,
                    Start = new DateTimeTimeZone
                    {
                        DateTime = start.ToString("o"),
                        // Set to the user's time zone
                        TimeZone = timeZone
                    },
                    End = new DateTimeTimeZone
                    {
                        DateTime = end.ToString("o"),
                        // Set to the user's time zone
                        TimeZone = timeZone
                    },
                    AllowNewTimeProposals = true
                };
    
                if (attendees.Count > 0)
                {
                    var requiredAttendees = new List<Attendee>();
    
                    foreach (var email in attendees)
                    {
                        requiredAttendees.Add(new Attendee
                        {
                            Type = AttendeeType.Required,
                            EmailAddress = new EmailAddress
                            {
                                Address = email
                            }
                        });
                    }
    
                    newEvent.Attendees = requiredAttendees;
                }
    
               if (!string.IsNullOrEmpty(body))
                {
                    newEvent.Body = new ItemBody
                    {
                        Content = "body test",
                        ContentType = BodyType.Text
                    };
               }
                    await graphClient.Users[userEmail]
                        .Calendar
                        .Events
                        .Request()
                        .AddAsync(newEvent);
    
                    return true;
    
    
            }
    

  3. Mike Backhouse 1 Reputation point
    2022-05-20T11:31:19.217+00:00

    Hi,

    I came across this thread having a similar issue. Our root cause was the API scope permissions that the user had. In addition to ability to create events in the calendar, the user also needed the Mail.Send scope. Once we applied this scope, the call worked including sending the notification mail to the invitees when the calendar event is created.

    HTH

    Mike

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.