1 /**
2  * Windows API header module
3  *
4  * Translated from MinGW Windows headers
5  *
6  * Authors: Stewart Gordon
7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8  * Source: $(DRUNTIMESRC core/sys/windows/_mapi.d)
9  */
10 module core.sys.windows.mapi;
11 version (Windows):
12 
13 import core.sys.windows.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 enum MAPI_LOGON_UI          = 0x0001;
58 enum MAPI_NEW_SESSION       = 0x0002;
59 enum MAPI_FORCE_DOWNLOAD    = 0x1000;
60 enum MAPI_LOGOFF_SHARED     = 0x0001;
61 enum MAPI_LOGOFF_UI         = 0x0002;
62 enum MAPI_DIALOG            = 0x0008;
63 enum MAPI_UNREAD_ONLY       = 0x0020;
64 enum MAPI_LONG_MSGID        = 0x4000;
65 enum MAPI_GUARANTEE_FIFO    = 0x0100;
66 enum MAPI_ENVELOPE_ONLY     = 0x0040;
67 enum MAPI_PEEK              = 0x0080;
68 enum MAPI_BODY_AS_FILE      = 0x0200;
69 enum MAPI_SUPPRESS_ATTACH   = 0x0800;
70 enum MAPI_AB_NOMODIFY       = 0x0400;
71 enum MAPI_OLE               = 0x0001;
72 enum MAPI_OLE_STATIC        = 0x0002;
73 enum MAPI_UNREAD            = 0x0001;
74 enum MAPI_RECEIPT_REQUESTED = 0x0002;
75 enum MAPI_SENT              = 0x0004;
76 
77 alias uint FLAGS;
78 alias uint* LPULONG;
79 alias ULONG_PTR LHANDLE;
80 alias ULONG_PTR* LPLHANDLE;
81 
82 struct MapiRecipDesc {
83     ULONG  ulReserved;
84     ULONG  ulRecipClass;
85     LPSTR  lpszName;
86     LPSTR  lpszAddress;
87     ULONG  ulEIDSize;
88     LPVOID lpEntryID;
89 }
90 alias MapiRecipDesc* lpMapiRecipDesc;
91 
92 struct MapiFileDesc {
93     ULONG  ulReserved;
94     ULONG  flFlags;
95     ULONG  nPosition;
96     LPSTR  lpszPathName;
97     LPSTR  lpszFileName;
98     LPVOID lpFileType;
99 }
100 alias MapiFileDesc* lpMapiFileDesc;
101 
102 struct MapiFileTagExt {
103     ULONG  ulReserved;
104     ULONG  cbTag;
105     LPBYTE lpTag;
106     ULONG  cbEncoding;
107     LPBYTE lpEncoding;
108 }
109 alias MapiFileTagExt* lpMapiFileTagExt;
110 
111 struct MapiMessage {
112     ULONG           ulReserved;
113     LPSTR           lpszSubject;
114     LPSTR           lpszNoteText;
115     LPSTR           lpszMessageType;
116     LPSTR           lpszDateReceived;
117     LPSTR           lpszConversationID;
118     FLAGS           flFlags;
119     lpMapiRecipDesc lpOriginator;
120     ULONG           nRecipCount;
121     lpMapiRecipDesc lpRecips;
122     ULONG           nFileCount;
123     lpMapiFileDesc  lpFiles;
124 }
125 alias MapiMessage* lpMapiMessage;
126 
127 extern (Windows) {
128     ULONG MAPILogon(ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE);
129     ULONG MAPISendMail(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG);
130     ULONG MAPISendDocuments(ULONG_PTR, LPSTR, LPSTR, LPSTR, ULONG);
131     ULONG MAPIReadMail(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, lpMapiMessage*);
132     ULONG MAPIFindNext(LHANDLE, ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPSTR);
133     ULONG MAPIResolveName(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG,
134       lpMapiRecipDesc*);
135     ULONG MAPIAddress(LHANDLE, ULONG_PTR, LPSTR, ULONG, LPSTR, ULONG,
136       lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*);
137     ULONG MAPIFreeBuffer(LPVOID);
138     ULONG MAPIDetails(LHANDLE, ULONG_PTR, lpMapiRecipDesc, FLAGS, ULONG);
139     ULONG MAPISaveMail(LHANDLE, ULONG_PTR, lpMapiMessage lpszMessage, FLAGS,
140       ULONG, LPSTR);
141     ULONG MAPIDeleteMail(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG);
142     ULONG MAPILogoff(LHANDLE, ULONG_PTR, FLAGS, ULONG);
143     // Netscape extensions
144     ULONG MAPIGetNetscapeVersion();
145     ULONG MAPI_NSCP_SynchronizeClient(LHANDLE, ULONG);
146 
147     // Handles for use with GetProcAddress
148     alias ULONG function(ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE)
149       LPMAPILOGON;
150     alias ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG)
151       LPMAPISENDMAIL;
152     alias ULONG function(ULONG_PTR, LPSTR, LPSTR, LPSTR, ULONG)
153       LPMAPISENDDOCUMENTS;
154     alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG, lpMapiMessage*)
155       LPMAPIREADMAIL;
156     alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, LPSTR, FLAGS, ULONG, LPSTR)
157       LPMAPIFINDNEXT;
158     alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG,
159       lpMapiRecipDesc*) LPMAPIRESOLVENAME;
160     alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, ULONG, LPSTR, ULONG,
161       lpMapiRecipDesc, FLAGS, ULONG, LPULONG, lpMapiRecipDesc*) LPMAPIADDRESS;
162     alias ULONG function(LPVOID lpv) LPMAPIFREEBUFFER;
163     alias ULONG function(LHANDLE, ULONG_PTR, lpMapiRecipDesc, FLAGS, ULONG)
164       LPMAPIDETAILS;
165     alias ULONG function(LHANDLE, ULONG_PTR, lpMapiMessage, FLAGS, ULONG, LPSTR)
166       LPMAPISAVEMAIL;
167     alias ULONG function(LHANDLE, ULONG_PTR, LPSTR, FLAGS, ULONG)
168       LPMAPIDELETEMAIL;
169     alias ULONG function(LHANDLE, ULONG_PTR, FLAGS, ULONG) LPMAPILOGOFF;
170 }