program.cs

来自「.net 获取msn联系人名单(转载) windows ApI」· CS 代码 · 共 74 行

CS
74
字号
//Code by Gnilly (http://gnillydev.blogspot.com)
//Offical site: http://opencontacts.sourceforge.net

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Lesser General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Lesser General Public License for more details.

//You should have received a copy of the GNU Lesser General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace OpenContactsNet.Test
{
    internal class Program
    {
        private static void Main( string[] args )
        {
            if ( args.Length < 2 )
            {
                Console.WriteLine( "Usage: OpenContactsNet.Test.exe <mail> <password>" );
                return;
            }

            MailContactList list = null;

            if ( args[ 0 ].ToLower().EndsWith( "gmail.com" ) )
            {
                Console.WriteLine( "Importing from Google Mail" );
                GmailExtract extractor = new GmailExtract();
                bool res = extractor.Extract( new NetworkCredential( args[ 0 ], args[ 1 ] ), out list );
                Console.WriteLine( res ? "Succeeded" : "Failed" );
            }
            else if ( args[ 0 ].ToLower().EndsWith( "yahoo.com" ) )
            {
                Console.WriteLine( "Importing from Yahoo! mail" );
                YahooExtract extractor = new YahooExtract();
                bool res = extractor.Extract( new NetworkCredential( args[ 0 ], args[ 1 ] ), out list );
                Console.WriteLine( res ? "Succeeded" : "Failed" );
            }
            else if ( args[ 0 ].ToLower().EndsWith( "live.com" ) || args[ 0 ].ToLower().EndsWith( "hotmail.com" ) )
            {
                Console.WriteLine( "Importing from Live mail" );
                LiveExtract extractor = new LiveExtract();
                bool res = extractor.Extract( new NetworkCredential( args[ 0 ], args[ 1 ] ), out list );
                Console.WriteLine( res ? "Succeeded" : "Failed" );
            }
            else
            {
                Console.WriteLine( "OpenContacts.NET doesn't support specified web mail service" );
            }

            if ( list != null )
            {
                Console.WriteLine( "{0} items imported", list.Count );
                foreach ( MailContact contact in list )
                {
                    Console.WriteLine( "EMail: {0} Name: {1}", contact.Email, contact.Name );
                }
            }

            Console.ReadKey();
        }
    }
}

⌨️ 快捷键说明

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