haiku-website/static/legacy-docs/bebook/BMailMessage_Overview.html

38 lines
7.7 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Mail Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheMailKit_Overview.html" title="The Mail Kit" /><link rel="prev" href="TheMailDaemon_Overview.html" title="The Mail Daemon" /><link rel="next" href="TheMediaKit_Overview.html" title="The Media Kit" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheMailDaemon_Overview.html" title="The Mail Daemon"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheMailKit_Overview.html" title="The Mail Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheMediaKit_Overview.html" title="The Media Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Mail Kit</div></div><div id="headerB">Prev: <a href="TheMailDaemon_Overview.html">The Mail Daemon</a>  Up: <a href="TheMailKit_Overview.html">The Mail Kit</a>  Next: <a href="TheMediaKit_Overview.html">The Media Kit</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMailMessage_Overview"></a>BMailMessage</h2></div></div></div><p>The <a class="link" href="BMailMessage.html" title="BMailMessage"><code class="classname">BMailMessage</code></a>
class provides an easy way to send e-mail messages. If
you want to do it the hard way, look up the
<acronym class="acronym" title="Simple Mail Transfer Protocol">SMTP</acronym>
<acronym class="acronym" title="Request For Comments">RFC</acronym>
and start plodding your way through the Network Kit documentation. You'll get it working one
of these days.</p><p>Or you can sail right on through and be sending e-mail from your own
applications in a matter of minutes using your friend, the
<a class="link" href="BMailMessage.html" title="BMailMessage"><code class="classname">BMailMessage</code></a>.</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMailMessage_ConstructingAMailMessage"></a>Constructing a Mail Message</h3></div></div></div><p>To send an e-mail, you simply construct a new
<a class="link" href="BMailMessage.html" title="BMailMessage"><code class="classname">BMailMessage</code></a> object, add a
"To" header field, add the content, and send the message on its way. For
example:</p><pre class="programlisting example cpp"><span class="type">BMailMessage *</span><code class="varname">mail</code>;
<span class="type">char *</span><code class="varname">message</code>;
<code class="varname">mail</code> = new <code class="classname">BMailMessage</code>();
<code class="varname">mail</code>-&gt;<code class="methodname">AddHeaderField</code>(<code class="constant">B_MAIL_TO</code>, "bob@uncle.com");
<code class="varname">mail</code>-&gt;<code class="methodname">AddHeaderField</code>(<code class="constant">B_MAIL_SUBJECT</code>, "Hi");
<code class="varname">message</code> = "Hi, Uncle Bob!";
<code class="varname">mail</code>-&gt;<code class="methodname">AddContent</code>(<code class="varname">message</code>, <code class="function">strlen</code>(<code class="varname">message</code>));</pre><p>This is a pretty basic message. The subject is "Hi," the message is sent
to "bob@uncle.com," and the message body is "Hi, Uncle Bob!"</p><p>You can add other fields, including carbon-copy (CC) and
blind-carbon-copy (BCC) fields, and you can add attachments. For example,
if you want to also attach a file called <code class="filename">/boot/home/file.zip</code>,
you can do the following:</p><pre class="programlisting example cpp"><code class="varname">mail</code>-&gt;<code class="methodname">AddEnclosure</code>("/boot/home/file.zip");</pre><p>Once your message has been constructed, you can send it by calling
<a class="link" href="BMailMessage.html#BMailMessage_Send" title="Send()"><code class="methodname">Send()</code></a>:</p><pre class="programlisting example cpp"><code class="varname">mail</code>-&gt;<code class="methodname">Send</code>();</pre><p>That's the basic technique behind sending e-mail under the BeOS. The mail
daemon also fetches incoming mail from a POP server, but you can't use
the <a class="link" href="BMailMessage.html" title="BMailMessage"><code class="classname">BMailMessage</code></a>
class to read these messages; you use the BeOS
<a class="link" href="BQuery.html" title="BQuery"><code class="classname">BQuery</code></a>
and <a class="link" href="BNode.html" title="BNode"><code class="classname">BNode</code></a>
classes to locate messages of interest and obtain information
about them. See "Querying Mail Messages" for more information.</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheMailDaemon_Overview.html">The Mail Daemon</a>  Up: <a href="TheMailKit_Overview.html">The Mail Kit</a>  Next: <a href="TheMediaKit_Overview.html">The Media Kit</a> </div><div id="footerB"><div id="footerBL"><a href="TheMailDaemon_Overview.html" title="The Mail Daemon"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheMailKit_Overview.html" title="The Mail Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheMediaKit_Overview.html" title="The Media Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>