//----Mail sample---------------------------------------------------------------
//Receive mail
Pop3Client cl = new
Pop3Client();
cl.ServerName = "your server name";
cl.UserName = "your name";
cl.Password = "pass";
cl.Ssl = false;
if (cl.Authenticate() == true)
{
Int32 MailIndex = 1;
MailMessage mg = cl.GetMessage(MailIndex);
String mailTo = mg.To;
String mailCc = mg.Cc;
String title = mg.Subject;
String bodyText = mg.BodyText;
//Save Image to your local hard disk
foreach(MailContent
ct in mg.Contents)
{
String filePath =
"C:\MyFolder\" + ct.ContentDisposition.FileName;
ct.DecodeData(filePath);
}
}
//Delete selected mail from mailbox
Pop3Client pop = new
Pop3Client("mymail@mydomain.com",
"mypass", "mail.myserver.com");
pop.Port = 110;
pop.AuthenticateMode = Pop3AuthenticateMode.Pop;
Int64[] DeleteIndexList =
new.....//It depend on your needs
cl.DeleteEMail(DeleteIndexList);
//Send mail
SmtpClient cl = new
SmtpClient();
cl.ServerName = "your server name";
cl.Port = 25;
cl.Ssl = false;
SmtpMessage mg = new
SmtpMessage();
mg.Subject = "title";
mg.BodyText = "Hi.my mail body text!";
//Send by HTML format
mg.IsHtml = true;
mg.From = "my_address@mail.com";
mg.To.Add(new MailAddress("address@mail.com"));
//Add attachment file from local disk
SmtpContent ct = new SmtpContent();
ct.LoadData("C:\\myFile.xls");
mg.Contents.Add(ct);
var rs = cl.SendMail(mg);
//Check mail was sent or not
if (rs.SendSuccessfull == false)
{
//You can get information about send mail is success or error reason
var resultState = rs.State;
}
//----Twitter Sync sample-----------------------------------------------------
var cl =
new
TwitterClient(consumerKey, consumerSecret, accessToken, accessTokenSecret);
var rr = cl.GetHomeTimeline();
foreach (
var
r
in rr)
{
Console.WriteLine(r.CreatedAt +
":" + r.Text);
}
cl.UpdateStatus(
"I feel happy!!");
//Add new tweet
//----Twitter Async sample(You can use this method on silverlight or WindowsPhone7)-------
var cl =
new
TwitterClient(consumerKey, consumerSecret, accessToken, accessTokenSecret);
//Execute callback on UI thread
cl.SetDispatcher(dispatcher);
//Observe error event when async call
cl.Error +=
new EventHandler<
AsyncCallErrorEventArgs>(OAuthClient_Error);
cl.GetHomeTimeline(rr =>
{
foreach (
var
r
in rr)
{
Console.WriteLine(r.CreatedAt +
":" + r.Text);
}
});
cl.UpdateStatus(
"I feel happy!!", status =>
Console.WriteLine(status.CreatedAt +
":" + status.Text));
//----Dropbox Sync sample------------------------------------------------
var t =
DropboxClient.GetAccessTokenInfo("consumerKey",
"email", "password");//Get access token
var cl =
new DropboxClient(
"consumerKey",
"consumerSecret", t.Token, t.TokenSecret);
var ai = cl.GetAccountInfo();
var cm1 =
new
GetMetadataCommand();
cm1.Path =
"/MyFile.txt";
var rr = cl.GetMetadata(cm1);
var cm2 =
new
UploadFileCommand();
cm2.FolderPath =
"/";
cm2.FileName =
"FileNameOnDropbox.txt";
Byte[] bb = ...
//You get byte data from your data source.
cm2.LoadFileData(bb);
cl.UploadFile(cm2);
//----Dropbox Async sample(You can use this method on silverlight or WindowsPhone7)---
var cl =
new
DropboxClient("consumerKey",
"consumerSecret", accessToken, accessTokenSecret);
//Execute callback on UI thread
cl.SetDispatcher(dispatcher);
//Observe error event when async call
cl.Error +=
new EventHandler<
AsyncCallErrorEventArgs>(OAuthClient_Error);
cl.GetAccountInfo(
new GetAccountCommand(), ai =>
Console.WriteLine(ai.EMail));
var cm1 =
new
GetMetadataCommand();
cm1.Path =
"/";
cl.GetMetadata(cm1, metaData =>
Console.WriteLine(metaData.Path));
//Observe Uploading data size.You can use it for progress bar feature.
cl.Uploading += (o, e) =>
Console.WriteLine(
"Total upload size is " + e.TotalSize);
var cm2 =
new
UploadFileCommand();
cm2.FolderPath =
"/";
cm2.FileName =
"FileNameOnDropbox.txt";
Byte[] bb = ...
//You get byte data from your data source.
cm2.LoadFileData(bb);
cl.UploadFile(cm2, response =>
Console.WriteLine(response.BodyText));
//----SugarSync Sync sample--------------------------------------------------------
var cl =
new
SugarSyncClient
("mailaddress",
"password",
"AccessKeyID",
"PrivateAccessKey");
cl.Authenticate();
var rs = cl.GetUserInfo();
//----Rss Sync sample--------------------------------------------------------
var cl =
new
RssClient();
var fd = cl.GetRssFeed
("http://www.website.com/rss.xml");
foreach (
var
item
in fd.Items)
{
//Read item property(Title,Link,PubDate) and do something.
}
//You can create new RssFeed instance from text data.
var fd1 =
new
RssFeed(System.IO.
File.ReadAllText(
"C:\\rss.xml");
//----Rss Async sample-------------------------------------------------------
var cl =
new RssClient();
cl.GetRssFeed
("http://www.website.com/rss.xml",
fd =>
{
foreach (
var
item
in fd.Items)
{
//Read item property(Title,Link,PubDate) and do something.
}
});
//----Facebook sample-------------------------------------------------------
var cl =
new
FacebookClient(token);
var u = cl.GetUser(
"123456789");
u = cl.GetUser(
"123456789");
var d = cl.GetFriends(
new
GetFriendsCommand());
foreach (
var
f
in d.FirendList)
{
var friendName = f.Name;
}