MVC 缓存

MVC  缓存

http://blog.zhaojie.me/2009/09/aspnet-mvc-fragment-cache-1.html

redis

http://www.cnblogs.com/wolf-sun/p/5404593.html

Exchange

https://msdn.microsoft.com/en-us/library/dn567668.aspx

public static void GetMailMessage(string userName, string passWord, string domain, string url)
{
ServicePointManager.ServerCertificateValidationCallback =
delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{ return true; };
//创建Exchange服务绑定对象
ExchangeServiceBinding exchangeServer = new ExchangeServiceBinding();
//创建安全身份凭证
ICredentials creds = new NetworkCredential(userName, passWord, domain);
//建立信任连接
exchangeServer.Credentials = creds;
exchangeServer.Url = url;

//定义邮件的收件箱
DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
folderIDArray[0] = new DistinguishedFolderIdType();
folderIDArray[0].Id = DistinguishedFolderIdNameType.inbox; //读取inbox文件夹下所有邮件,不包括子文件夹
//folderIDArray[0].Id = DistinguishedFolderIdNameType.tasks;//读取Task文件夹下的所有任务,不包括子文件夹

//设置要读取所需满足的条件
PathToUnindexedFieldType ptuftDisplayName = new PathToUnindexedFieldType();
ptuftDisplayName.FieldURI = UnindexedFieldURIType.folderDisplayName;

PathToExtendedFieldType pteftComment = new PathToExtendedFieldType();
pteftComment.PropertyTag = "0x3004";
pteftComment.PropertyType = MapiPropertyTypeType.String;

GetFolderType myfoldertype = new GetFolderType();
myfoldertype.FolderIds = folderIDArray;
myfoldertype.FolderShape = new FolderResponseShapeType();
myfoldertype.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;
myfoldertype.FolderShape.AdditionalProperties = new BasePathToElementType[2];
myfoldertype.FolderShape.AdditionalProperties[0] = ptuftDisplayName;
myfoldertype.FolderShape.AdditionalProperties[1] = pteftComment;

//获取Exchange邮件系统中指定类型文件夹信息
GetFolderResponseType myFolder = exchangeServer.GetFolder(myfoldertype);

FolderInfoResponseMessageType firmtInbox =
(FolderInfoResponseMessageType)myFolder.ResponseMessages.Items[0];

PathToUnindexedFieldType ptuftSubject = new PathToUnindexedFieldType();
ptuftSubject.FieldURI = UnindexedFieldURIType.itemSubject;

PathToUnindexedFieldType ptuftBody = new PathToUnindexedFieldType();
ptuftBody.FieldURI = UnindexedFieldURIType.itemAttachments;

PathToExtendedFieldType pteftFlagStatus = new PathToExtendedFieldType();
pteftFlagStatus.PropertyTag = "0x1090";
pteftFlagStatus.PropertyType = MapiPropertyTypeType.Integer;

// 定义FindItemType对象,准备获取收件箱中的集合
FindItemType findItemRequest = new FindItemType();
findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
findItemRequest.ItemShape = new ItemResponseShapeType();
findItemRequest.ItemShape.BaseShape = DefaultShapeNamesType.Default;

findItemRequest.ParentFolderIds = new FolderIdType[1];
findItemRequest.ParentFolderIds[0] = firmtInbox.Folders[0].FolderId;

//获取指定收件箱中的邮件集合
FindItemResponseType firt = exchangeServer.FindItem(findItemRequest);

MessageType mt = new MessageType(); //邮件类型
int newEmail = 0;//Unread email number
foreach (FindItemResponseMessageType firmtMessage in firt.ResponseMessages.Items)
{
if (firmtMessage.RootFolder.TotalItemsInView > 0)
{
foreach (ItemType it in ((ArrayOfRealItemsType)firmtMessage.RootFolder.Item).Items)
{
mt = it as MessageType;
if (mt != null)
{

if (!mt.IsRead) //判断邮件是否是已读还是未读
newEmail++;
else
continue;
}

#region Eg codes

#endregion
}

string sf=newEmail.ToString();

}
}
}

上一篇:restful-----------------------------接口设计方式(一种风格)


下一篇:Python sqlalchemy的基本使用