问题描述
我现在正在做EWS二次开发,有段代码不能获取邮件类容和邮件附件,那位大侠指点一下。///<summary>///显示邮件///</summary>///<paramname="address">获取邮件人地址</param>///<returns></returns>#regionGetNewMailpublicList<MessageType>GetNewMail(stringaddress){FindItemTypefindItemRequest=newFindItemType();findItemRequest.Traversal=ItemQueryTraversalType.Shallow;ItemResponseShapeTypeitemProperties=newItemResponseShapeType();itemProperties.BaseShape=DefaultShapeNamesType.AllProperties;//============//BodyTypeResponseTypebtype=newBodyTypeResponseType();//itemProperties.BodyType=btype;//============findItemRequest.ItemShape=itemProperties;EmailAddressTypebox=newEmailAddressType();//box.MailboxType=MailboxTypeType.Mailbox;box.EmailAddress=address;DistinguishedFolderIdType[]folderIDArray=newDistinguishedFolderIdType[1];folderIDArray[0]=newDistinguishedFolderIdType();folderIDArray[0].Id=DistinguishedFolderIdNameType.inbox;folderIDArray[0].Mailbox=box;findItemRequest.ParentFolderIds=folderIDArray;//查询条件RestrictionTyperestriction=GetMailRestrictionByUnRead();if(restriction!=null)findItemRequest.Restriction=restriction;try{FindItemResponseTypefindItemResponse=esb.FindItem(findItemRequest);ResponseMessageType[]rmta=findItemResponse.ResponseMessages.Items;returngetMail(refrmta);}catch(Exceptione){throw(e);}}//获取邮件privateList<MessageType>getMail(refResponseMessageType[]rmta){List<MessageType>newMails=newList<MessageType>(30);if(rmta!=null){foreach(ResponseMessageTypermtinrmta){if(rmtisFindItemResponseMessageType){FindItemResponseMessageTypefindItemResponse=(FindItemResponseMessageType)rmt;if(findItemResponse.ResponseClass==ResponseClassType.Success){if(findItemResponse.RootFolder.ItemisArrayOfRealItemsType){;ArrayOfRealItemsTypeobj=(ArrayOfRealItemsType)findItemResponse.RootFolder.Item;//----//----if(obj!=null&&obj.Items!=null){foreach(ItemTypeiteminobj.Items){if(itemisMessageType){MessageTypemessage=(MessageType)item;if(message!=null){newMails.Add(message);}}}}}}}}}returnnewMails;}privateRestrictionTypeGetMailRestrictionByUnRead(){RestrictionTyperestriction=newRestrictionType();IsEqualToTypeisEqual=newIsEqualToType();FieldURIOrConstantType_fieldURIOrConstantType=newFieldURIOrConstantType();ConstantValueType_constant=newConstantValueType();//控制读取邮件类型_constant.Value="0";_fieldURIOrConstantType.Item=_constant;PathToUnindexedFieldType_pathToUnindexedFieldType=newPathToUnindexedFieldType();_pathToUnindexedFieldType.FieldURI=UnindexedFieldURIType.messageIsRead;isEqual.FieldURIOrConstant=_fieldURIOrConstantType;isEqual.Item=_pathToUnindexedFieldType;restriction.Item=isEqual;returnrestriction;}#endregion
解决方案
解决方案二:
通过EMAILItemID在读取一次我的MSN:yang_chun2010@hotmail.com
解决方案三:
你是通过那种方式做二次开发的。
解决方案四:
你好,请问exchange2010中的ExchangeServiceBinding这个类的dll你有吗?我这边引用了webservice,但是还是不行,能不能发给我一下,谢谢了!邮箱:caoqiancc@yahoo.com.cn