Fix problems with non-ASCII chars in attachment paths, subject, body and other meta...
[TortoiseGit.git] / src / Utils / MailMsg.h
blob8a939a3802b8fdbd1257e586ada49a4435ffa6ee
1 /*************************************************************************************
2 This file is a part of CrashRpt library.
4 Copyright (c) 2003, Michael Carruth
5 All rights reserved.
7 Adjusted by Sven Strickroth <email@cs-ware.de>, 2011-2018
8 * added flag to show mail compose dialog
9 * make it work with 32-64bit inconsistencies (http://msdn.microsoft.com/en-us/library/dd941355.aspx)
10 * auto extract filenames of attachments
11 * make work with multiple recipients (to|cc)
12 * fix non ascii chars in subject, text and attachment paths
13 * See Git history of the TortoiseGit project for more details
15 Redistribution and use in source and binary forms, with or without modification,
16 are permitted provided that the following conditions are met:
18 * Redistributions of source code must retain the above copyright notice, this
19 list of conditions and the following disclaimer.
21 * Redistributions in binary form must reproduce the above copyright notice,
22 this list of conditions and the following disclaimer in the documentation
23 and/or other materials provided with the distribution.
25 * Neither the name of the author nor the names of its contributors
26 may be used to endorse or promote products derived from this software without
27 specific prior written permission.
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
31 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
32 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
33 SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
35 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
36 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ***************************************************************************************/
41 ///////////////////////////////////////////////////////////////////////////////
43 // Module: MailMsg.h
45 // Desc: This class encapsulates the MAPI mail functions.
47 // Copyright (c) 2003 Michael Carruth
49 ///////////////////////////////////////////////////////////////////////////////
51 #ifndef _MAILMSG_H_
52 #define _MAILMSG_H_
54 typedef std::map<CString, CString> TStrStrMap;
56 typedef struct MailAddress
58 CString email;
59 CString name;
61 MailAddress() {};
63 MailAddress(const CString& email, const CString& name)
64 : email(email)
65 , name(name)
67 } MailAddress;
69 // ===========================================================================
70 // CMailMsg
72 // See the module comment at top of file.
74 class CMailMsg
76 public:
77 // Construction/destruction
78 CMailMsg();
80 // Operations
81 void SetTo(const CString& sAddress);
82 void SetFrom(const CString& sAddresses, const CString& sName);
83 void SetSubject(const CString& sSubject);
84 void SetMessage(const CString& sMessage);
85 void AddAttachment(const CString& sAttachment, CString sTitle = L"");
86 void SetCC(const CString& sAddresses);
87 void SetShowComposeDialog(BOOL showComposeDialog);
89 BOOL MAPIInitialize();
91 static BOOL DetectMailClient(CString& sMailClientName);
92 BOOL Send();
93 CString GetLastErrorMsg(){ return m_sErrorMsg; }
95 protected:
96 MailAddress m_from;
97 std::vector<MailAddress> m_to; // To receipients
98 TStrStrMap m_attachments; // Attachment <file,title>
99 std::vector<MailAddress> m_cc; // CC receipients
100 CString m_sSubject; // EMail subject
101 CString m_sMessage; // EMail message
103 BOOL m_bShowComposeDialog;
105 CString m_sErrorMsg;
108 #endif // _MAILMSG_H_