Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create an appointment in MS Outlook Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-Jan-03
Category
OLE
Language
Delphi 2.x
Views
84
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How to create an appointment in MS Outlook

Answer:

Today I want to continue a serie of tips for MS Outlook automatization from Delphi.

If you want to create a new appointment, you can use a code sample below:

1   uses ComObj;
2   
3   procedure CreateNewAppointment;
4   const
5     olAppointmentItem = $00000001;
6   
7     olImportanceLow = 0;
8     olImportanceNormal = 1;
9     olImportanceHigh = 2;
10  
11    {to find a default Contacts folder}
12    function GetCalendarFolder(folder: OLEVariant): OLEVariant;
13    var
14      i: Integer;
15    begin
16      for i := 1 to folder.Count do
17      begin
18        if (folder.Item[i].DefaultItemType = olAppointmentItem) then
19        begin
20          Result := folder.Item[i];
21          break
22        end
23        else
24          Result := GetCalendarFolder(folder.Item[i].Folders);
25      end;
26    end;
27  
28  var
29    outlook, ns, folder, appointment: OLEVariant;
30  begin
31    {initialize an Outlook}
32    outlook := CreateOLEObject('Outlook.Application');
33    {get MAPI namespace}
34    ns := outlook.GetNamespace('MAPI');
35    {get a default Contacts folder}
36    folder := GetCalendarFolder(ns.Folders);
37    {if Contacts folder is found}
38    if not VarIsNull(folder) then
39    begin
40      {create a new item}
41      appointment := folder.Items.Add(olAppointmentItem);
42      {define a subject and body of appointment}
43      appointment.Subject := 'new appointment';
44      appointment.Body := 'call me tomorrow';
45  
46      {duration: 10 days starting from today}
47      appointment.Start := Now();
48      appointment.end := Now() + 10; {10 days for execution}
49      appointment.AllDayEvent := 1; {all day event}
50  
51      {set reminder in 20 minutes}
52      appointment.ReminderMinutesBeforeStart := 20;
53      appointment.ReminderSet := 1;
54  
55      {set a high priority}
56      appointment.Importance := olImportanceHigh;
57  
58      {to save an appointment}
59      appointment.Save;
60  
61      {to display an appointment}
62      appointment.Display(True);
63  
64      {to print a form}
65      appointment.PrintOut;
66    end;
67  
68    {to free all used resources}
69    folder := UnAssigned;
70    ns := UnAssigned;
71    outlook := UnAssigned
72  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC