Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cMailMessage.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cMailMessage_H
7 #define _INC_cMailMessage_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
15 
16 namespace GrayLib
17 {
19 
21  {
25 #define cMailTagDEF(a,b,c,d) MAIL_TAG_##a,
26 #include "cMailTags.tbl"
27 #undef cMailTagDEF
29  };
30 
32  {
37 
38  public:
41 
42  public:
43  cMailName(cStringA sAddr = "", cStringA sName = "")
44  : m_sAddr(sAddr)
45  , m_sName(sName)
46  {
47  }
48  StrLen_t GRAYCALL SetParsedName(const char* pszLine);
49  cStringA GetFullName() const;
51  {
52  return CheckValidEmailAddressFormat(m_sAddr);
53  }
54 
55  static bool GRAYCALL IsValidEmailAddressChar(wchar_t ch);
56  static HRESULT GRAYCALL CheckValidEmailAddressFormat(const char* pszEmail);
57  };
58 
60  {
64 
65  public:
66  static const char* k_aszTags[MAIL_TAG_QTY + 1];
69 
70  public:
71  cMailTag(MAIL_TAG_TYPE eTag = MAIL_TAG_UNK, cStringA sVal = "") noexcept
72  : m_eTag(eTag), m_sVal(sVal)
73  {
74  }
75  MAIL_TAG_TYPE get_HashCode() const noexcept
76  {
77  return m_eTag;
78  }
79 
80  static StrLen_t GRAYCALL GetSizeWriteTag(MAIL_TAG_TYPE eTag, cStringA sTag);
81  static HRESULT GRAYCALL WriteTag(cStreamOutput* pOut, MAIL_TAG_TYPE eTag, cStringA sTag);
82 
83  HRESULT WriteTag(cStreamOutput* pOut) const;
84  };
85 
87  {
92 
93  friend class cMailTag;
94 
95  protected:
97 
98  public:
99  // Header
101 
102  // RCPT TO: can iterate for multiple receivers
105 
106  // Body
109 
110  public:
111  cMailMessage();
112  ~cMailMessage();
113 
114  HRESULT CheckValidMessage() const;
115 
116  cStringA GetToEntry(int i = 0) const;
117  ITERATE_t SetToList(const char* pszDestList);
118 
119  bool HasTag(MAIL_TAG_TYPE eTag, const char* pszVal=nullptr) const;
120  cStringA GetTag(MAIL_TAG_TYPE eTag) const;
121  HRESULT SetTag(MAIL_TAG_TYPE eTag, cStringA sVal);
122  void SetTagInt(MAIL_TAG_TYPE eTag, int iVal);
123 
124  HRESULT put_BodyStr(const char* pszBody);
125 
126  HRESULT SendMailMessage(cStreamOutput& o, bool bBody = true);
127 
129  };
130 };
131 #endif // _INC_cMailMessage_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cMailMessage.h:87
cArrayStringA m_aBody
body text of the message. each line to be followed by CR
Definition: cMailMessage.h:108
cArraySortStructHash< cMailTag > m_aTags
SMTP tags that are in this message. e.g. MAIL_TAG_From, MAIL_TAG_Subject.
Definition: cMailMessage.h:96
cMailName m_From
Source email address. MAIL FROM: and MAIL_TAG_From.
Definition: cMailMessage.h:100
cArrayStruct< cMailName > m_aCC
list of destination email address(s). CC: BCC:
Definition: cMailMessage.h:104
cArrayStruct< cMailName > m_aTo
list of destination email address(s). TO: MAIL_TAG_To
Definition: cMailMessage.h:103
bool m_bFormatHTML
Encode the message body as HTML or not. MAIL_TAG_Content_Type = MIME_HTML.
Definition: cMailMessage.h:107
UNITTEST_FRIEND(cMailMessage)
Definition: cMailMessage.h:32
cStringA m_sAddr
Email address. e.g. "name@menasoft.com".
Definition: cMailMessage.h:39
cStringA m_sName
Friendly name. e.g. "Dennis Robinson".
Definition: cMailMessage.h:40
HRESULT CheckValidEmailAddressFormat() const
Definition: cMailMessage.h:50
cMailName(cStringA sAddr="", cStringA sName="")
Definition: cMailMessage.h:43
Definition: cMailMessage.h:60
cStringA m_sVal
the value may be int,'string' or enum constant.
Definition: cMailMessage.h:68
MAIL_TAG_TYPE get_HashCode() const noexcept
Definition: cMailMessage.h:75
cMailTag(MAIL_TAG_TYPE eTag=MAIL_TAG_UNK, cStringA sVal="") noexcept
Definition: cMailMessage.h:71
MAIL_TAG_TYPE m_eTag
What tag type? one of each per header. order is not important.
Definition: cMailMessage.h:67
Definition: cArraySort.h:363
Definition: cArray.h:932
Definition: cStream.h:126
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
MAIL_TAG_TYPE
Definition: cMailMessage.h:21
@ MAIL_TAG_QTY
Definition: cMailMessage.h:28
@ MAIL_TAG_UNK
Definition: cMailMessage.h:24
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
int ITERATE_t
like size_t but signed
Definition: Index.h:28