EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #205 background imageLoading...
Page #205 background image
Emailing Directly from an Arduino
To send an email from the Arduino, well basically implement the
telnet
session
from the previous chapter. Instead of hardwiring the emails attributes into
the networking code, well create create something more advanced.
We start with an
Email
class:
Ethernet/Email/email.h
#ifndef __EMAIL__H_
#define __EMAIL__H_
class Email {
String _from, _to, _subject, _body;
public:
Email(
const String& from,
const String& to,
const String& subject,
const String& body
) : _from(from), _to(to), _subject(subject), _body(body) {}
const String& getFrom() const { return _from; }
const String& getTo() const { return _to; }
const String& getSubject() const { return _subject; }
const String& getBody() const { return _body; }
};
#endif
This class encapsulates an emails four most important attributesthe email
addresses of the sender and the recipient, a subject, and a message body.
We store all attributes as
String
objects.
Wait a minutea
String
class? Yes! The Arduino IDE comes with a full-blown
string class.
4
It doesnt have as many features as the C++ or Java string
classes, but its still way better than messing around with
char
pointers. Youll
see how to use it in a few paragraphs.
The rest of our
Email
class is pretty straightforward. In the constructor, we
initialize all instance variables, and we have methods for getting every single
attribute. We now need an
SmtpService
class for sending
Email
objects:
4.
http://arduino.cc/en/Reference/StringObject
report erratum discuss
Emailing Directly from an Arduino 189
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals