MailMessage.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * MailMessage.h
8  *
9  * @author Slavey Karadzhov <slaff@attachix.com>
10  *
11  ****/
12 
19 #pragma once
20 
21 #include "WString.h"
22 #include "WVector.h"
23 #include "Http/HttpHeaders.h"
24 #include <Data/WebConstants.h>
27 #include <Data/Stream/FileStream.h>
28 
29 class SmtpClient;
30 
32 {
33  friend class SmtpClient;
34 
35 public:
40 
47  MailMessage& setHeader(const String& name, const String& value)
48  {
49  headers[name] = value;
50  return *this;
51  }
52 
58 
65  MailMessage& setBody(const String& body, MimeType mime = MIME_TEXT);
66 
73  MailMessage& setBody(String&& body, MimeType mime = MIME_TEXT) noexcept;
74 
82 
89 
97  MailMessage& addAttachment(IDataSourceStream* stream, MimeType mime, const String& filename = "");
98 
106  MailMessage& addAttachment(IDataSourceStream* stream, const String& mime, const String& filename = "");
107 
108 private:
109  IDataSourceStream* stream = nullptr;
110  HttpHeaders headers;
112 };
113 
String to
Definition: MailMessage.h:36
HttpHeaders & getHeaders()
Get a reference to the current set of headers.
Base class for read-only stream.
Definition: DataSourceStream.h:40
String subject
Definition: MailMessage.h:38
Definition: MailMessage.h:31
The String class.
Definition: WString.h:136
Encapsulates a set of HTTP header information.
Definition: HttpHeaders.h:34
File stream class.
Definition: FileStream.h:20
MailMessage & setHeader(const String &name, const String &value)
Set a header value.
Definition: MailMessage.h:47
String cc
Definition: MailMessage.h:39
MailMessage & setBody(const String &body, MimeType mime=MIME_TEXT)
Sets the body of the email.
MailMessage & addAttachment(FileStream *stream)
Adds attachment to the email.
Definition: SmtpClient.h:90
String from
Definition: MailMessage.h:37
IDataSourceStream * stream
The currently active stream being sent.
Definition: TcpClient.h:157
MimeType
Definition: WebConstants.h:53