Symbian3/SDK/Source/GUID-D73AD200-BE4D-50BF-BCF9-14627DE530B7.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-D73AD200-BE4D-50BF-BCF9-14627DE530B7" xml:lang="en"><title>Imap4Example:
An Email manager using IMAP4 and SMTP</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-A3DDBA67-40D7-572D-A5CE-ED78D7A977DC"><title>Description</title> <p>This
example application demonstrates how to create SMTP (Simple Mail Transfer
Protocol) and IMAP (Internet Message Access Protocol) accounts to send and
receive emails respectively. The application creates dummy messages and sends
them using SMTP. </p> <p>The application starts a session with the messaging
server using <xref href="GUID-2DA04D96-F0AD-3FDC-9E36-1C27D889AF4B.dita#GUID-2DA04D96-F0AD-3FDC-9E36-1C27D889AF4B/GUID-423E2320-FB34-3249-80D9-9AA62C9DDF60"><apiname>CMsvSession::OpenSyncL()</apiname></xref> and gets an instance
of the client MTM (Message Type Module) registry using <xref href="GUID-A0682D04-9084-3DC3-AA18-5B81A78A1DA8.dita#GUID-A0682D04-9084-3DC3-AA18-5B81A78A1DA8/GUID-DBD7038B-A0E2-3791-A4C9-3A22FFCA146A"><apiname>CClientMtmRegistry::NewL()</apiname></xref>.
Using this registry it creates IMAP4 client-side MTM objects for the specified
UID. </p> <p>After creating the client MTM objects, the application creates
IMAP4 and SMTP accounts using <xref href="GUID-A7EF08E6-82AF-3577-B942-ABD532EDB7FE.dita#GUID-A7EF08E6-82AF-3577-B942-ABD532EDB7FE/GUID-3FECFA5C-3C53-3BD2-A710-D6069C08EB08"><apiname>CEmailAccounts::CreateImapAccountL()</apiname></xref> and <xref href="GUID-A7EF08E6-82AF-3577-B942-ABD532EDB7FE.dita#GUID-A7EF08E6-82AF-3577-B942-ABD532EDB7FE/GUID-89066942-2526-3B2E-B6DC-FCEF9EC2EFB6"><apiname>CEmailAccounts::CreateSmtpAccountL()</apiname></xref> respectively.
Settings and preferences for these accounts are configured using the <xref href="GUID-55F11633-988C-39D5-ADE7-23C4966FD995.dita"><apiname>CImImap4Settings</apiname></xref>, <xref href="GUID-9CAB9BE5-7233-3A01-A906-756177CF4460.dita"><apiname>CImIAPPreferences</apiname></xref> and <xref href="GUID-DFE18962-0022-3833-A8F0-6E4C969177C0.dita"><apiname>CImSmtpSettings</apiname></xref>. </p> <p>A simple SMTP message is created by the
application using the <xref href="GUID-3F7DC1AB-D13C-31E9-967B-526AD72CD498.dita#GUID-3F7DC1AB-D13C-31E9-967B-526AD72CD498/GUID-FCDC47D2-0446-3CD7-A246-4DCED7C8A063"><apiname>CImEmailOperation::CreateNewL()</apiname></xref> function,
and then sent to the email address stored in the literal <codeph>KTo</codeph>. </p> <p> <b>Note</b>:
Each email account created by the application has a pair of service entries,
which are used to store settings required for email transport. </p> <p>The
application also provides the <codeph>CMessAsyncWaiter</codeph> class to issue
asynchronous requests to the messaging server and handles completed requests.
This class implements the <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive</apiname></xref> abstract interface. </p> </section>
<section id="GUID-F52C49C9-3072-5046-B5EF-F4C22CAEBD0F"><title>Download</title> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-62d00653-18c4-48af-94b0-4debade064f2.zip" scope="external">Imap4Example.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-62d00653-18c4-48af-94b0-4debade064f2.html" scope="peer">browse</xref> to view the example code. </p> </section>
<section id="GUID-7AE47DB2-8A48-54AC-8BD8-1A3CE5573331"><title>Pre-requisites</title> <p>A
null modem cable (NTRAS - New Technology Remote Access Services) must be connected
to your system for the example to be functional. Also, change the values of
literals <codeph>KSmtpServerAddress</codeph> and <codeph>KImapServer</codeph> defined
in the <filepath>imap4example.cpp</filepath> file to your system address. </p> <p>In
addition to the above mentioned changes, you must have an account with the
messaging server. You can create an account using any messaging proxy server
application such as Communigate-Pro, which is freely downloadable from <xref href="http://www.stalker.com/CommuniGatePro/#Current" scope="external">http://www.stalker.com/CommuniGatePro/</xref>.
The name of the newly created account can either be the account name used
by the application or a different one. If you choose to name the new account
different from the account name used by the application, change the value
of the literal <codeph>KImapLoginName</codeph> defined in the <filepath>imap4example.cpp</filepath> file
to the new account name. </p> <p> <b>Note</b>: To check the messages sent
by the application, you must configure your email client to retrieve messages
for the newly created IMAP4 account. For information on how to configure your
email client, refer its user guide. </p> </section>
<section><title>Class Summary</title><p><xref href="GUID-A7EF08E6-82AF-3577-B942-ABD532EDB7FE.dita"><apiname>CEmailAccounts</apiname></xref></p><p> <xref href="GUID-BDE23754-4536-3AF7-8549-3B953F51167C.dita"><apiname>MMsvSessionObserver</apiname></xref></p><p> <xref href="GUID-513528C7-4741-3494-9272-4E8F6CDBF20F.dita"><apiname>TMsvSessionEvent</apiname></xref></p><p> <xref href="GUID-A0682D04-9084-3DC3-AA18-5B81A78A1DA8.dita"><apiname>CClientMtmRegistry</apiname></xref></p><p> <xref href="GUID-2DA04D96-F0AD-3FDC-9E36-1C27D889AF4B.dita"><apiname>CMsvSession</apiname></xref></p><p> <xref href="GUID-177AF50B-14EF-3C45-AE22-1FEE5678261D.dita"><apiname>CBaseMtm</apiname></xref></p><p> <xref href="GUID-AF724192-6580-3DE3-9287-3A005C0AA932.dita"><apiname>CMsvOperation</apiname></xref></p><p> <xref href="GUID-A4B1F874-27C0-3BB6-9D29-C35C75A5DB98.dita"><apiname>TMsvId</apiname></xref></p><p> <xref href="GUID-12FC6AC7-8946-324D-B2B7-60B332870794.dita"><apiname>TImapAccount</apiname></xref></p><p> <xref href="GUID-C1545507-56B1-3533-9D7D-1F17F95AB6F8.dita"><apiname>TSmtpAccount</apiname></xref></p><p> <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive</apiname></xref> </p></section>
<section id="GUID-ABD7370A-98DF-58D0-90F7-72684A11798E"><title>Build</title> <p>The <xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">Symbian OS build process</xref> describes
how to build an application. </p> <p>The IMAP4 example builds an executable
called <filepath>impa4Example.exe</filepath> in the standard location (<filepath>\epoc32\release\winscw\</filepath> <i>&lt;build_variant&gt;</i> for
CodeWarrior). After launching the executable, depending on the emulator you
are using, you may need to task away from the app launcher/shell screen to
view the console. </p> </section>
<section id="GUID-43E4D1FA-8CF0-5F5B-A166-30AE01E6D961"><title>See also</title> <p> <xref href="GUID-1F755804-70D6-5635-B2F7-06F03C8D4B74.dita">IMAP4 MTM Overview</xref>  </p> <p> <xref href="GUID-4F703F85-080F-5B77-B94D-5449764828F3.dita">SMTP MTM Overview</xref>  </p> </section>
</conbody></concept>