home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / RTLWIN32.PAK / TNEF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  14.0 KB  |  386 lines

  1. /*
  2.  *  T N E F . H
  3.  *
  4.  *
  5.  *  This file contains structure and function definitions for the
  6.  *  MAPI implementation of the Transport Neutral Encapsilation Format
  7.  *  used by MAPI providers for the neutral serialization of a MAPI
  8.  *  message.  This implementation sits on top of the IStream object as
  9.  *  documented in the OLE 2 Specs.
  10.  *
  11.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  12.  */
  13.  
  14. #ifndef TNEF_H
  15. #define TNEF_H
  16. #pragma option -b
  17.  
  18. #ifdef __BORLANDC__
  19. #pragma option -b.
  20.   #include <pshpack8.h>
  21. #pragma option -b
  22. #endif
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28.  
  29. #ifndef BEGIN_INTERFACE
  30. #define BEGIN_INTERFACE
  31. #endif
  32.  
  33. /* ------------------------------------ */
  34. /* TNEF Problem and TNEF Problem Arrays */
  35. /* ------------------------------------ */
  36.  
  37. typedef struct _STnefProblem
  38. {
  39.     ULONG   ulComponent;
  40.     ULONG   ulAttribute;
  41.     ULONG   ulPropTag;
  42.     SCODE   scode;
  43. } STnefProblem;
  44.  
  45. typedef struct _STnefProblemArray
  46. {
  47.     ULONG           cProblem;
  48.     STnefProblem    aProblem[MAPI_DIM];
  49. } STnefProblemArray, FAR * LPSTnefProblemArray;
  50.  
  51. #define CbNewSTnefProblemArray(_cprob) \
  52.     (offsetof(STnefProblemArray,aProblem) + (_cprob)*sizeof(STnefProblem))
  53. #define CbSTnefProblemArray(_lparray) \
  54.     (offsetof(STnefProblemArray,aProblem) + \
  55.     (UINT) ((_lparray)->cProblem*sizeof(STnefProblem)))
  56.  
  57. /* Pointers to TNEF Interface ---------------------------------------- */
  58.  
  59. DECLARE_MAPI_INTERFACE_PTR(ITnef, LPITNEF);
  60.  
  61. /*  OpenTNEFStream */
  62.  
  63. #define TNEF_DECODE                 ((ULONG) 0)
  64. #define TNEF_ENCODE                 ((ULONG) 2)
  65.  
  66. #define TNEF_PURE                   ((ULONG) 0x00010000)
  67. #define TNEF_COMPATIBILITY          ((ULONG) 0x00020000)
  68. #define TNEF_BEST_DATA              ((ULONG) 0x00040000)
  69. #define TNEF_COMPONENT_ENCODING     ((ULONG) 0x80000000)
  70.  
  71. /*  AddProps, ExtractProps */
  72.  
  73. #define TNEF_PROP_INCLUDE           ((ULONG) 0x00000001)
  74. #define TNEF_PROP_EXCLUDE           ((ULONG) 0x00000002)
  75. #define TNEF_PROP_CONTAINED         ((ULONG) 0x00000004)
  76. #define TNEF_PROP_MESSAGE_ONLY      ((ULONG) 0x00000008)
  77. #define TNEF_PROP_ATTACHMENTS_ONLY  ((ULONG) 0x00000010)
  78. #define TNEF_PROP_CONTAINED_TNEF    ((ULONG) 0x00000040)
  79.  
  80. /*  FinishComponent */
  81.  
  82. #define TNEF_COMPONENT_MESSAGE      ((ULONG) 0x00001000)
  83. #define TNEF_COMPONENT_ATTACHMENT   ((ULONG) 0x00002000)
  84.  
  85. #define MAPI_ITNEF_METHODS(IPURE)                                       \
  86.     MAPIMETHOD(AddProps)                                                \
  87.         (THIS_  ULONG                       ulFlags,                    \
  88.                 ULONG                       ulElemID,                   \
  89.                 LPVOID                      lpvData,                    \
  90.                 LPSPropTagArray             lpPropList) IPURE;          \
  91.     MAPIMETHOD(ExtractProps)                                            \
  92.         (THIS_  ULONG                       ulFlags,                    \
  93.                 LPSPropTagArray             lpPropList,                 \
  94.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  95.     MAPIMETHOD(Finish)                                                  \
  96.         (THIS_  ULONG                       ulFlags,                    \
  97.                 WORD FAR *                  lpKey,                      \
  98.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  99.     MAPIMETHOD(OpenTaggedBody)                                          \
  100.         (THIS_  LPMESSAGE                   lpMessage,                  \
  101.                 ULONG                       ulFlags,                    \
  102.                 LPSTREAM FAR *              lppStream) IPURE;           \
  103.     MAPIMETHOD(SetProps)                                                \
  104.         (THIS_  ULONG                       ulFlags,                    \
  105.                 ULONG                       ulElemID,                   \
  106.                 ULONG                       cValues,                    \
  107.                 LPSPropValue                lpProps) IPURE;             \
  108.     MAPIMETHOD(EncodeRecips)                                            \
  109.         (THIS_  ULONG                       ulFlags,                    \
  110.                 LPMAPITABLE                 lpRecipientTable) IPURE;    \
  111.     MAPIMETHOD(FinishComponent)                                         \
  112.         (THIS_  ULONG                       ulFlags,                    \
  113.                 ULONG                       ulComponentID,              \
  114.                 LPSPropTagArray             lpCustomPropList,           \
  115.                 LPSPropValue                lpCustomProps,              \
  116.                 LPSPropTagArray             lpPropList,                 \
  117.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  118.  
  119. #undef       INTERFACE
  120. #define      INTERFACE  ITnef
  121. DECLARE_MAPI_INTERFACE_(ITnef, IUnknown)
  122. {
  123.     BEGIN_INTERFACE
  124.     MAPI_IUNKNOWN_METHODS(PURE)
  125.     MAPI_ITNEF_METHODS(PURE)
  126. };
  127.  
  128. STDMETHODIMP OpenTnefStream(
  129.     LPVOID              lpvSupport,
  130.     LPSTREAM            lpStream,
  131.     LPTSTR              lpszStreamName,
  132.     ULONG               ulFlags,
  133.     LPMESSAGE           lpMessage,
  134.     WORD                wKeyVal,
  135.     LPITNEF FAR *       lppTNEF);
  136.  
  137. typedef HRESULT (STDMETHODCALLTYPE FAR * LPOPENTNEFSTREAM) (
  138.     LPVOID              lpvSupport,
  139.     LPSTREAM            lpStream,
  140.     LPTSTR              lpszStreamName,
  141.     ULONG               ulFlags,
  142.     LPMESSAGE           lpMessage,
  143.     WORD                wKeyVal,
  144.     LPITNEF FAR *       lppTNEF);
  145.  
  146. STDMETHODIMP OpenTnefStreamEx(
  147.     LPVOID              lpvSupport,
  148.     LPSTREAM            lpStream,
  149.     LPTSTR              lpszStreamName,
  150.     ULONG               ulFlags,
  151.     LPMESSAGE           lpMessage,
  152.     WORD                wKeyVal,
  153.     LPADRBOOK           lpAdressBook,
  154.     LPITNEF FAR *       lppTNEF);
  155.  
  156. typedef HRESULT (STDMETHODCALLTYPE FAR * LPOPENTNEFSTREAMEX) (
  157.     LPVOID              lpvSupport,
  158.     LPSTREAM            lpStream,
  159.     LPTSTR              lpszStreamName,
  160.     ULONG               ulFlags,
  161.     LPMESSAGE           lpMessage,
  162.     WORD                wKeyVal,
  163.     LPADRBOOK           lpAdressBook,
  164.     LPITNEF FAR *       lppTNEF);
  165.  
  166. STDMETHODIMP GetTnefStreamCodepage (
  167.     LPSTREAM            lpStream,
  168.     ULONG FAR *         lpulCodepage,
  169.     ULONG FAR *         lpulSubCodepage);
  170.  
  171. typedef HRESULT (STDMETHODCALLTYPE FAR * LPGETTNEFSTREAMCODEPAGE) (
  172.     LPSTREAM            lpStream,
  173.     ULONG FAR *         lpulCodepage,
  174.     ULONG FAR *         lpulSubCodepage);
  175.  
  176. #define OPENTNEFSTREAM "OpenTnefStream"
  177. #define OPENTNEFSTREAMEX "OpenTnefStreamEx"
  178. #define GETTNEFSTREAMCODEPAGE "GetTnefStreamCodePage"
  179.  
  180. /* -------------------------- */
  181. /* TNEF Signature and Version */
  182. /* -------------------------- */
  183.  
  184. #define MAKE_TNEF_VERSION(_mj,_mn)  (((ULONG)(0x0000FFFF & _mj) << 16) | (ULONG)(0x0000FFFF & _mn))
  185. #define TNEF_SIGNATURE  ((ULONG) 0x223E9F78)
  186. #define TNEF_VERSION    ((ULONG) MAKE_TNEF_VERSION(1,0))
  187.  
  188.  
  189. /* ------------------------------------------- */
  190. /* TNEF Down-level Attachment Types/Structures */
  191. /* ------------------------------------------- */
  192.  
  193. typedef WORD ATYP;
  194. enum { atypNull, atypFile, atypOle, atypPicture, atypMax };
  195.  
  196. #define MAC_BINARY  ((DWORD) 0x00000001)
  197.  
  198. #pragma pack (1)
  199. typedef struct _renddata
  200. {
  201.     ATYP    atyp;
  202.     ULONG   ulPosition;
  203.     WORD    dxWidth;
  204.     WORD    dyHeight;
  205.     DWORD   dwFlags;
  206.  
  207. } RENDDATA, *PRENDDATA;
  208. #pragma pack ()
  209.  
  210.  
  211. /* ----------------------------------- */
  212. /* TNEF Down-level Date/Time Structure */
  213. /* ----------------------------------- */
  214.  
  215. #pragma pack (1)
  216. typedef struct _dtr
  217. {
  218.     WORD    wYear;
  219.     WORD    wMonth;
  220.     WORD    wDay;
  221.     WORD    wHour;
  222.     WORD    wMinute;
  223.     WORD    wSecond;
  224.     WORD    wDayOfWeek;
  225.  
  226. } DTR;
  227. #pragma pack ()
  228.  
  229.  
  230. /* ----------------------------- */
  231. /* TNEF Down-level Message Flags */
  232. /* ----------------------------- */
  233.  
  234. #define fmsNull         ((BYTE) 0x00)
  235. #define fmsModified     ((BYTE) 0x01)
  236. #define fmsLocal        ((BYTE) 0x02)
  237. #define fmsSubmitted    ((BYTE) 0x04)
  238. #define fmsRead         ((BYTE) 0x20)
  239. #define fmsHasAttach    ((BYTE) 0x80)
  240.  
  241.  
  242. /* ----------------------------------------- */
  243. /* TNEF Down-level Triple Address Structures */
  244. /* ----------------------------------------- */
  245.  
  246. #define trpidNull                   ((WORD) 0x0000)
  247. #define trpidUnresolved             ((WORD) 0x0001)
  248. #define trpidResolvedNSID           ((WORD) 0x0002)
  249. #define trpidResolvedAddress        ((WORD) 0x0003)
  250. #define trpidOneOff                 ((WORD) 0x0004)
  251. #define trpidGroupNSID              ((WORD) 0x0005)
  252. #define trpidOffline                ((WORD) 0x0006)
  253. #define trpidIgnore                 ((WORD) 0x0007)
  254. #define trpidClassEntry             ((WORD) 0x0008)
  255. #define trpidResolvedGroupAddress   ((WORD) 0x0009)
  256. typedef struct _trp
  257. {
  258.     WORD    trpid;
  259.     WORD    cbgrtrp;
  260.     WORD    cch;
  261.     WORD    cbRgb;
  262.  
  263. } TRP, *PTRP, *PGRTRP, FAR * LPTRP;
  264. #define CbOfTrp(_p)     (sizeof(TRP) + (_p)->cch + (_p)->cbRgb)
  265. #define LpszOfTrp(_p)   ((LPSTR)(((LPTRP) (_p)) + 1))
  266. #define LpbOfTrp(_p)    (((LPBYTE)(((LPTRP)(_p)) + 1)) + (_p)->cch)
  267. #define LptrpNext(_p)   ((LPTRP)((LPBYTE)(_p) + CbOfTrp(_p)))
  268.  
  269. typedef DWORD XTYPE;
  270. #define xtypeUnknown    ((XTYPE) 0)
  271. #define xtypeInternet   ((XTYPE) 6)
  272.  
  273. #define cbDisplayName   41
  274. #define cbEmailName     11
  275. #define cbSeverName     12
  276. typedef struct _ADDR_ALIAS
  277. {
  278.     char    rgchName[cbDisplayName];
  279.     char    rgchEName[cbEmailName];
  280.     char    rgchSrvr[cbSeverName];
  281.     ULONG   dibDetail;
  282.     WORD    type;
  283.  
  284. } ADDRALIAS, FAR * LPADDRALIAS;
  285. #define cbALIAS sizeof(ALIAS)
  286.  
  287. #define cbTYPE              16
  288. #define cbMaxIdData         200
  289. typedef struct _NSID
  290. {
  291.     DWORD   dwSize;
  292.     unsigned char   uchType[cbTYPE];
  293.     XTYPE   xtype;
  294.     LONG    lTime;
  295.  
  296.     union
  297.     {
  298.         ADDRALIAS   alias;
  299.         char        rgchInterNet[1];
  300.  
  301.     } address;
  302.  
  303. } NSID, * LPNSID;
  304. #define cbNSID sizeof(NSID)
  305.  
  306.  
  307. /* -------------------------- */
  308. /* TNEF Down-level Priorities */
  309. /* -------------------------- */
  310.  
  311. #define prioLow     3
  312. #define prioNorm    2
  313. #define prioHigh    1
  314.  
  315.  
  316. /* ------------------------------------- */
  317. /* TNEF Down-level Attributes/Properties */
  318. /* ------------------------------------- */
  319.  
  320. #define atpTriples      ((WORD) 0x0000)
  321. #define atpString       ((WORD) 0x0001)
  322. #define atpText         ((WORD) 0x0002)
  323. #define atpDate         ((WORD) 0x0003)
  324. #define atpShort        ((WORD) 0x0004)
  325. #define atpLong         ((WORD) 0x0005)
  326. #define atpByte         ((WORD) 0x0006)
  327. #define atpWord         ((WORD) 0x0007)
  328. #define atpDword        ((WORD) 0x0008)
  329. #define atpMax          ((WORD) 0x0009)
  330.  
  331. #define LVL_MESSAGE     ((BYTE) 0x01)
  332. #define LVL_ATTACHMENT  ((BYTE) 0x02)
  333.  
  334. #define ATT_ID(_att)                ((WORD) ((_att) & 0x0000FFFF))
  335. #define ATT_TYPE(_att)              ((WORD) (((_att) >> 16) & 0x0000FFFF))
  336. #define ATT(_atp, _id)              ((((DWORD) (_atp)) << 16) | ((WORD) (_id)))
  337.  
  338. #define attNull                     ATT( 0,             0x0000)
  339. #define attFrom                     ATT( atpTriples,    0x8000) /* PR_ORIGINATOR_RETURN_ADDRESS */
  340. #define attSubject                  ATT( atpString,     0x8004) /* PR_SUBJECT */
  341. #define attDateSent                 ATT( atpDate,       0x8005) /* PR_CLIENT_SUBMIT_TIME */
  342. #define attDateRecd                 ATT( atpDate,       0x8006) /* PR_MESSAGE_DELIVERY_TIME */
  343. #define attMessageStatus            ATT( atpByte,       0x8007) /* PR_MESSAGE_FLAGS */
  344. #define attMessageClass             ATT( atpWord,       0x8008) /* PR_MESSAGE_CLASS */
  345. #define attMessageID                ATT( atpString,     0x8009) /* PR_MESSAGE_ID */
  346. #define attParentID                 ATT( atpString,     0x800A) /* PR_PARENT_ID */
  347. #define attConversationID           ATT( atpString,     0x800B) /* PR_CONVERSATION_ID */
  348. #define attBody                     ATT( atpText,       0x800C) /* PR_BODY */
  349. #define attPriority                 ATT( atpShort,      0x800D) /* PR_IMPORTANCE */
  350. #define attAttachData               ATT( atpByte,       0x800F) /* PR_ATTACH_DATA_xxx */
  351. #define attAttachTitle              ATT( atpString,     0x8010) /* PR_ATTACH_FILENAME */
  352. #define attAttachMetaFile           ATT( atpByte,       0x8011) /* PR_ATTACH_RENDERING */
  353. #define attAttachCreateDate         ATT( atpDate,       0x8012) /* PR_CREATION_TIME */
  354. #define attAttachModifyDate         ATT( atpDate,       0x8013) /* PR_LAST_MODIFICATION_TIME */
  355. #define attDateModified             ATT( atpDate,       0x8020) /* PR_LAST_MODIFICATION_TIME */
  356. #define attAttachTransportFilename  ATT( atpByte,       0x9001) /* PR_ATTACH_TRANSPORT_NAME */
  357. #define attAttachRenddata           ATT( atpByte,       0x9002)
  358. #define attMAPIProps                ATT( atpByte,       0x9003)
  359. #define attRecipTable               ATT( atpByte,       0x9004) /* PR_MESSAGE_RECIPIENTS */
  360. #define attAttachment               ATT( atpByte,       0x9005)
  361. #define attTnefVersion              ATT( atpDword,      0x9006)
  362. #define attOemCodepage              ATT( atpByte,       0x9007)
  363. #define attOriginalMessageClass     ATT( atpWord,       0x0006) /* PR_ORIG_MESSAGE_CLASS */
  364.  
  365. #define attOwner                    ATT( atpByte,       0x0000) /* PR_RCVD_REPRESENTING_xxx  or
  366.                                                                    PR_SENT_REPRESENTING_xxx */
  367. #define attSentFor                  ATT( atpByte,       0x0001) /* PR_SENT_REPRESENTING_xxx */
  368. #define attDelegate                 ATT( atpByte,       0x0002) /* PR_RCVD_REPRESENTING_xxx */
  369. #define attDateStart                ATT( atpDate,       0x0006) /* PR_DATE_START */
  370. #define attDateEnd                  ATT( atpDate,       0x0007) /* PR_DATE_END */
  371. #define attAidOwner                 ATT( atpLong,       0x0008) /* PR_OWNER_APPT_ID */
  372. #define attRequestRes               ATT( atpShort,      0x0009) /* PR_RESPONSE_REQUESTED */
  373.  
  374. #ifdef __cplusplus
  375. }
  376. #endif
  377.  
  378. #ifdef __BORLANDC__
  379. #pragma option -b.
  380.   #include <poppack.h>
  381. #pragma option -b
  382. #endif
  383.  
  384. #pragma option -b.
  385. #endif  /*  defined TNEF_H */
  386.