How to create Event using Apex in Salesforce?

How to create Event using Apex in Salesforce?

Sample Code:

Event objEvent = new Event();
objEvent.Type = 'Email';
objEvent.Subject = 'Test';
objEvent.Description = 'Testing'; 
objEvent.StartDateTime = System.now();
objEvent.EndDateTime = System.now().addMinutes( 60 );
objEvent.Location = 'Sample';
insert objEvent;

Output:

Leave a Reply