1 /***********************************************************************\
2 *                                 mapi.d                                *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module win32.mapi;
12 
13 private import win32.windef;
14 
15 // FIXME: check types and grouping of constants
16 
17 enum {
18 	SUCCESS_SUCCESS,
19 	MAPI_USER_ABORT,
20 	MAPI_E_USER_ABORT        = MAPI_USER_ABORT,
21 	MAPI_E_FAILURE,
22 	MAPI_E_LOGIN_FAILURE,
23 	MAPI_E_LOGON_FAILURE     = MAPI_E_LOGIN_FAILURE,
24 	MAPI_E_DISK_FULL	     = 4,
25 	MAPI_E_INSUFFICIENT_MEMORY,
26 	MAPI_E_ACCESS_DENIED,
27 	MAPI_E_BLK_TOO_SMALL     = MAPI_E_ACCESS_DENIED, // = 6
28 	MAPI_E_TOO_MANY_SESSIONS = 8,
29 	MAPI_E_TOO_MANY_FILES,
30 	MAPI_E_TOO_MANY_RECIPIENTS,
31 	MAPI_E_ATTACHMENT_NOT_FOUND,
32 	MAPI_E_ATTACHMENT_OPEN_FAILURE,
33 	MAPI_E_ATTACHMENT_WRITE_FAILURE,
34 	MAPI_E_UNKNOWN_RECIPIENT,
35 	MAPI_E_BAD_RECIPTYPE,
36 	MAPI_E_NO_MESSAGES,
37 	MAPI_E_INVALID_MESSAGE,
38 	MAPI_E_TEXT_TOO_LARGE,
39 	MAPI_E_INVALID_SESSION,
40 	MAPI_E_TYPE_NOT_SUPPORTED,
41 	MAPI_E_AMBIGUOUS_RECIPIENT,
42 	MAPI_E_AMBIGUOUS_RECIP   = MAPI_E_AMBIGUOUS_RECIPIENT,
43 	MAPI_E_MESSAGE_IN_USE,
44 	MAPI_E_NETWORK_FAILURE,
45 	MAPI_E_INVALID_EDITFIELDS,
46 	MAPI_E_INVALID_RECIPS,
47 	MAPI_E_NOT_SUPPORTED  // = 26
48 }
49 
50 enum {
51 	MAPI_ORIG,
52 	MAPI_TO,
53 	MAPI_CC,
54 	MAPI_BCC
55 }
56 
57 const MAPI_LOGON_UI          = 0x0001;
58 const MAPI_NEW_SESSION       = 0x0002;
59 const MAPI_FORCE_DOWNLOAD    = 0x1000;
60 const MAPI_LOGOFF_SHARED     = 0x0001;
61 const MAPI_LOGOFF_UI         = 0x0002;
62 const MAPI_DIALOG            = 0x0008;
63 const MAPI_UNREAD_ONLY       = 0x0020;
64 const MAPI_LONG_MSGID        = 0x4000;
65 const MAPI_GUARANTEE_FIFO    = 0x0100;
66 const MAPI_ENVELOPE_ONLY     = 0x0040;
67 const MAPI_PEEK              = 0x0080;
68 const MAPI_BODY_AS_FILE      = 0x0200;
69 const MAPI_SUPPRESS_ATTACH   = 0x0800;
70 const MAPI_AB_NOMODIFY       = 0x0400;
71 const MAPI_OLE               = 0x0001;
72 const MAPI_OLE_STATIC        = 0x0002;
73 const MAPI_UNREAD            = 0x0001;
74 const MAPI_RECEIPT_REQUESTED = 0x0002;
75 const MAPI_SENT              = 0x0004;
76 
77 alias uint FLAGS, LHANDLE;
78 alias uint* LPLHANDLE, LPULONG;
79 
80 struct MapiRecipDesc {
81 	ULONG  ulReserved;
82 	ULONG  ulRecipClass;
83 	LPSTR  lpszName;
84 	LPSTR  lpszAddress;
85 	ULONG  ulEIDSize;
86 	LPVOID lpEntryID;
87 }
88 alias MapiRecipDesc* lpMapiRecipDesc;
89 
90 struct MapiFileDesc {
91 	ULONG  ulReserved;
92 	ULONG  flFlags;
93 	ULONG  nPosition;
94 	LPSTR  lpszPathName;
95 	LPSTR  lpszFileName;
96 	LPVOID lpFileType;
97 }
98 alias MapiFileDesc* lpMapiFileDesc;
99 
100 struct MapiFileTagExt {
101 	ULONG  ulReserved;
102 	ULONG  cbTag;
103 	LPBYTE lpTag;
104 	ULONG  cbEncoding;
105 	LPBYTE lpEncoding;
106 }
107 alias MapiFileTagExt* lpMapiFileTagExt;
108 
109 struct MapiMessage {
110 	ULONG           ulReserved;
111 	LPSTR           lpszSubject;
112 	LPSTR           lpszNoteText;
113 	LPSTR           lpszMessageType;
114 	LPSTR           lpszDateReceived;
115 	LPSTR           lpszConversationID;
116 	FLAGS           flFlags;
117 	lpMapiRecipDesc lpOriginator;
118 	ULONG           nRecipCount;
119 	lpMapiRecipDesc lpRecips;
120 	ULONG           nFileCount;
121 	lpMapiFileDesc  lpFiles;
122 }
123 alias MapiMessage* lpMapiMessage;
124 
125 extern (Pascal) {
126 	ULONG MAPILogon(ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE);
127 	ULONG MAPISendMail(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG);
128 	ULONG MAPISendDocuments(ULONG, LPSTR, LPSTR, LPSTR, ULONG);
129 	ULONG MAPIReadMail(LHANDLE, ULONG, LPSTR, FLAGS, ULONG, lpMapiMessage*);
130 	ULONG MAPIFindNext(LHANDLE, ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPSTR);
131 	ULONG MAPIResolveName(LHANDLE, ULONG, LPSTR, FLAGS, ULONG,
132 	  lpMapiRecipDesc*);
133 	ULONG MAPIAddress(LHANDLE, ULONG, LPSTR, ULONG, LPSTR, ULONG,
134 	  lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*);
135 	ULONG MAPIFreeBuffer(LPVOID);
136 	ULONG MAPIDetails(LHANDLE, ULONG, lpMapiRecipDesc, FLAGS, ULONG);
137 	ULONG MAPISaveMail(LHANDLE, ULONG, lpMapiMessage lpszMessage, FLAGS,
138 	  ULONG, LPSTR);
139 	ULONG MAPIDeleteMail(LHANDLE lpSession, ULONG, LPSTR, FLAGS, ULONG);
140 	ULONG MAPILogoff(LHANDLE, ULONG, FLAGS, ULONG);
141 	// Netscape extensions
142 	ULONG MAPIGetNetscapeVersion();
143 	ULONG MAPI_NSCP_SynchronizeClient(LHANDLE, ULONG);
144 
145 	// Handles for use with GetProcAddress
146 	alias ULONG function(ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE)
147 	  LPMAPILOGON;
148 	alias ULONG function(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG)
149 	  LPMAPISENDMAIL;
150 	alias ULONG function(ULONG, LPSTR, LPSTR, LPSTR, ULONG)
151 	  LPMAPISENDDOCUMENTS;
152 	alias ULONG function(LHANDLE, ULONG, LPSTR, FLAGS, ULONG, lpMapiMessage*)
153 	  LPMAPIREADMAIL;
154 	alias ULONG function(LHANDLE, ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPSTR)
155 	  LPMAPIFINDNEXT;
156 	alias ULONG function(LHANDLE, ULONG, LPSTR, FLAGS, ULONG,
157 	  lpMapiRecipDesc*) LPMAPIRESOLVENAME;
158 	alias ULONG function(LHANDLE, ULONG, LPSTR, ULONG, LPSTR, ULONG,
159 	  lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*) LPMAPIADDRESS;
160 	alias ULONG function(LPVOID lpv) LPMAPIFREEBUFFER;
161 	alias ULONG function(LHANDLE, ULONG, lpMapiRecipDesc, FLAGS, ULONG)
162 	  LPMAPIDETAILS;
163 	alias ULONG function(LHANDLE, ULONG, lpMapiMessage, FLAGS, ULONG, LPSTR)
164 	  LPMAPISAVEMAIL;
165 	alias ULONG function(LHANDLE lpSession, ULONG, LPSTR, FLAGS, ULONG)
166 	  LPMAPIDELETEMAIL;
167 	alias ULONG function(LHANDLE, ULONG, FLAGS, ULONG) LPMAPILOGOFF;
168 }