This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appointment.cs
executable file
·168 lines (143 loc) · 4.41 KB
/
appointment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*---------------------------------------------------------------------
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
----------------------------------------------------------------------- *
* File: Appointment.cs
*
* Purpose: Managed representiation of the IAppointment class
*
*
*
* Notes:
*
*/
namespace PocketOutlook
{
using System;
using System.Runtime.InteropServices;
using MsgBox = System.Windows.Forms.MessageBox;
public class Appointment : OutlookItem
{
private Application m_application;
// The constructor is internal to prevent objects outside of the
// PocketOutlook library from using "new" to create an object of
// this type.
internal Appointment(Application application,
ref IntPtr pIAppointment) :
base(application, ref pIAppointment)
{
m_application = application;
}
public String Subject
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Subject(this.RawItemPtr, ref bz);
String zSubject = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zSubject = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zSubject;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Subject(this.RawItemPtr, value));
}
} // Subject
public String Body
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Body(this.RawItemPtr, ref bz);
String zBody = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zBody = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zBody;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Body(this.RawItemPtr, value));
}
} // Body
public String Location
{
set
{
PocketOutlook.CheckHRESULT(do_put_Location(this.RawItemPtr, value));
}
} // Subject
protected override void doSave()
{
PocketOutlook.CheckHRESULT(do_Save(this.RawItemPtr));
}
public void Send()
{
PocketOutlook.CheckHRESULT(do_Send(this.RawItemPtr));
}
protected override OutlookItem doCopy()
{
throw new NotSupportedException();
}
protected override void doDelete()
{
throw new NotSupportedException();
}
public Recipients Recipients
{
get
{
IntPtr pRecipients = new IntPtr(0);
long hResult = do_get_Recipients(this.RawItemPtr, ref pRecipients);
try
{
PocketOutlook.CheckHRESULT( (int) hResult);
}
catch (Exception)
{
PocketOutlook.ReleaseCOMPtr(pRecipients);
throw;
}
return new Recipients(m_application, pRecipients);
}
}
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_get_Subject") ]
private static extern int do_get_Subject(IntPtr self,
ref IntPtr rbzSubject);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_put_Subject") ]
private static extern int do_put_Subject(IntPtr self, String zBody);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_get_Body") ]
private static extern int do_get_Body(IntPtr self,
ref IntPtr rzBody);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_put_Body") ]
private static extern int do_put_Body(IntPtr self, String zBody);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_put_Location") ]
private static extern int do_put_Location(IntPtr self, String zBody);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_Save") ]
private static extern int do_Save(IntPtr self);
[ DllImport("PocketOutlook.dll", EntryPoint="IAppointment_Send") ]
private static extern int do_Send(IntPtr self);
[DllImport("PocketOutlook.dll", EntryPoint="IAppointment_get_Recipients")]
private static extern int do_get_Recipients(IntPtr self, ref IntPtr pRecipients);
}
}