Cancelling Meeting Requests with Calendar
You can send a meeting cancellation request with Aspose.Email using the Appointment Class object. You need to have the original meeting request information to cancel the request. The example in this article first sends a meeting request, saves the information in a database and then cancels the request based of the message ID.
Sending Meeting Requests
Before we can cancel meeting requests, we have to send some out:
- First create an instance of type SmtpClient for sending the message.
- To gather attendee information, we have created a data grid so that users can enter the names and addresses of people whom the invitation should be sent.
- After doing a for-each loop on the Rows collection of the grid, save all the attendee information in the MailAddressCollection collection.
- Create an instance of the MailMessage class and necessary properties like From, To and Subject.
- Create an instance of type Appointment and give location, start time, end time, organizers and attendees information.
- Save all the information in an SQL Server database. DB related work is being done in the SaveIntoDB method.
The following code snippet shows you how to send meeting requests.
Cancelling Meeting Request
To cancel a meeting request, first get the email message’s message ID. Since we have saved this information in a database for this example, we can easily get it again. We have used a grid to load all the sent messages. The screenshot of the form is as below:
- Selecting the row for which to send the cancellation request.
- Click Send Cancel Request to send the request.
- The code gets the ID from the selected row of the grid and queries the database to get the attendee, message and calendar related information.
- Create an instances of the Calendar Class and MailMessage class classes using the information retrieved from the database.
- Use the Appointment.CancelAppointment() method to send the cancellation request.
- Send the mail using the SMTP.
The following code snippet shows you how to cancel the meeting request.