I haven't come to the blog Park for a long time. I 've been busy working and learning. Today, I shared my encapsulated class libraries for getting MSN friend information, including gmai.com, yahoo.cn, yahoo.com.cn, live.cn, live.com, and hotmail.com email contacts.
In fact, there is no technical content, but I found several Class Libraries for a long time at work. To make it easy to use, I made it into a class library. Provides the mail group function. The following is a simple example.
There are several classes in the batch. helper namespace: gmailhelper, livehelper, msnhelper, and yahoohelper. Each class has a way To get mailbox contacts.
The public list <string> getlinkmans (string username, string password) class contains this method to obtain the address book contact. Account format to write, such as: dirain@yahoo.cn
Msnhelper is a bit special. He is responsible for getting friends in MSN. The public list <string> getfriendmail () obtains the MSN friend email address, and the public list <entity. msnfriend> getfriends () obtains the friend details, including the phone number and name.
Batch. entity has two entity classes. mailinfo is the required information for sending emails. Msnfriend is the detailed information of MSN friends.
In batch. Common, a mail sending class Sendmail is provided, which supports single-user sending and group sending.
You only need to reference batch. dll, xihsolutions. dotmsn. dll, opencontactsnet. dll, but those DLL files must be placed in a directory.
Case study of getting email address book contacts:
Get Email Contact
Batch. helper. gmailhelper Gmail = New Batch. helper. gmailhelper ();
List < String > List = Gmail. getlinkmans ( " Dirainme@gmail.com " , " 123123 " );
Obtain the MSN friend list and send an email to each friend:
Get MSN friends and send emails to friends
Msnhelper msn = New Msnhelper ();
MSN. Start ( " MSN account " , " MSN password " );
List < Msnfriend > List = MSN. getfriends (); // Get friends
Mailinfo m = New Mailinfo ();
M. Username = " Dirainme@gmail.com " ; // Sender account
M. Password = " 123123 " ; // Email Password
M. SMTP = " Smtp.gmail.com " ; // SMTP Server
M. Port = 587 ; // SMTP Server Service port
M. SSL = True ; // SSL encryption?
M. Title = " Email Subject " ;
M. Body = " <H1> email content " ;
// Get friend emial
Foreach (Msnfriend msnf In List)
{
M. addto (msnf. Email );
}
M. isbodyhtml = True ; // Content parsing HTML
Sendmail send = New Sendmail (m );
Send. Send ();
The addto method of mailinfo is to add the recipient. If there is one person, add it once.
Without any technical knowledge, it is to collect and encapsulate other class libraries. As to how the contact is obtained, there is a way of thinking, but it is not implemented in detail. MSN gets friends through the dotmsn component. The contact person in the email address book uses regular expressions to extract real data from the source code of the web page by simulating the login mailbox. This is an idea. If you are interested, you can study it and share your ideas with others. As for the API interfaces provided by various mailboxes, I haven't found them for a long time, and only Gmail provides them. Leave a message if you have any questions.
Http://files.cnblogs.com/dirain/Batch.rar
Source code please: http://www.dirain.cn/