⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailtest.cpp

📁 funambol windows mobile plugin source code, the source code is taken from the funambol site
💻 CPP
字号:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

#include "base/fscapi.h"
#include "base/util/utils.h"
#include "base/Log.h"
#include "spds/spdsutils.h"
#include <stdio.h>

#include "spds/MailMessage.h"
#include "spds/EmailData.h"

// Read a text file and convert it from UTF-8 to WCHAR
static int readFromFile(const char* path, WCHAR **message, size_t *len)
{
    char *msg = 0;
    size_t msglen;

    // Read file
    int ret = readFile(path, &msg, &msglen);
    if(ret)
        return ret;
    msg[msglen]=0;
    // Convert content
    *message = utf82wc(msg);
    *len=wcslen(*message);
    // Free memory
    delete [] msg;

    return 0;
}

#ifdef _WIN32_WCE
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd )
#else
int main(int argc, char** argv)
#endif
{
    size_t msglen=0;
    WCHAR *name[10], *msg=0;
    int i;
    const WCHAR *attach;

#ifdef _WIN32_WCE
    name[0] = stringdup(TEXT("message.xml"));
    name[1] = stringdup(TEXT("text.xml"));
    name[2] = NULL;
    attach = TEXT("/synclog.txt");
#else
    for(i=1; i<argc; i++)
       name[i-1] = utf82wc(argv[i]);
    name[i-1] = NULL;
    attach = TEXT("c:/windows/temp/synclog.txt");
#endif
    LOG.setLevel(LOG_LEVEL_DEBUG); // Force debug level for this test.

    // Test parse/format loop if names were given on cmdline
    for (i=0; name[i]; i++) {
        msg = loadAndConvert(name[i]);
        if( !msg ){
            WCHAR dbg[256];
            wsprintf(dbg, TEXT("Can't open file %s\n"), name[i]);
	        LOG.error(dbg);
            continue;
        }

    	EmailData em;

        if (em.parse(msg))
            fprintf(stderr, "Parse failed on: %S\n", name[i]);

        delete [] msg;

        WCHAR outname[10];
        wsprintf(outname, TEXT("msgout%d.xml"), i);
        if ( convertAndSave( outname, em.format() ) ) {
            fprintf(stderr, "Error in convertAndSave(em)\n");
        }
    }

    // Try to send a new mail with attachment
    EmailData newmail;
    MailMessage n;
    BodyPart body;

    body.setContent(TEXT("Ma che bella la citt

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -