reference: Pop3

git-svn-id: svn://ultimatepp.org/upp/trunk@7092 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-03-25 09:04:50 +00:00
parent 4e7a10108a
commit becef7dfc0
5 changed files with 82 additions and 1 deletions

View file

@ -1,4 +1,4 @@
description "Using layouts for dialogs";
description "Using layouts for dialogs\377";
uses
CtrlLib;
@ -9,3 +9,4 @@ file
mainconfig
"" = "GUI";

4
reference/Layout/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Layout_icpp_init_stub
#define _Layout_icpp_init_stub
#include "CtrlLib/init"
#endif

59
reference/Pop3/Pop3.cpp Normal file
View file

@ -0,0 +1,59 @@
#include <Core/POP3/POP3.h>
using namespace Upp;
// WIN32: This example requires OpenSSL .dlls to be available
CONSOLE_APP_MAIN
{
Cout() << "Your GMail username: ";
String user = ReadStdIn();
Cout() << "Your GMail password: ";
String pass = ReadStdIn();
Pop3 pop3;
pop3.Host("pop.gmail.com")
.Port(995)
.User(user, pass)
.SSL()
.Trace(); // Activate logging of Pop3.
Cout() << "Connecting to GMail POP3 server... ";
if(!pop3.Login()) {
Cout() << "Failed: " << pop3.GetLastError() << "\n";
return;
}
int msgcount = pop3.GetMessageCount();
if(msgcount < 0) {
Cout() << "\nFailed: " << pop3.GetLastError() << "\n";
pop3.Logout();
return;
}
Cout() << "There are " << msgcount << " messages in your inbox.\n";
for(;;) {
Cout() << "Message number to retrieve (1.." << msgcount << ") or anything else to QUIT:";
int i = StrInt(ReadStdIn());
if(i >= 1 && i <= msgcount) {
String message = pop3.GetMessage(i);
if(IsNull(message))
Cout() << "An error encountered: " << pop3.GetLastError() << "\n";
else {
InetMessage m;
if(m.Read(message)) {
Cout() << "Subject: " << m["subject"] << "\n"
<< "From: " << m["from"] << "\n"
<< "Date: " << m["date"] << "\n";
for(int i = 0; i < m.GetPartCount(); i++)
Cout() << "========= Part " << i << ", type "
<< Nvl(m.GetPartHeader(i, "content-type"), m["content-type"]) << "\n"
<< m.GetPartBody(i);
Cout() << "-------------------------------------\n";
}
else
Cout() << "Error parsing the message\n";
}
}
else
break;
}
Cout() << "Logging out!..\n";
pop3.Logout();
}

12
reference/Pop3/Pop3.upp Normal file
View file

@ -0,0 +1,12 @@
description "Examples of using Core/POP3 package to download gmail emails\377";
uses
Core,
Core/POP3;
file
Pop3.cpp;
mainconfig
"" = "SSE2";

5
reference/Pop3/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _Pop3_icpp_init_stub
#define _Pop3_icpp_init_stub
#include "Core/init"
#include "Core/POP3/init"
#endif