メールクライアントであるiOSアプリを書いています。いくつかの制限により、メールボックスを操作するには EWS (Exchange Web Services) を使用する必要があります。私にできることは、SOAP リクエストをサーバーに送信して必要な情報を取得することだけです。これまでのところ、SyncFolderItems Operationを使用して各フォルダー内のメッセージのリストを取得できました。その後、GetItem (E-mail Message) Operationを使用して各アイテムの詳細を取得しています。最後のリクエストでは、メールの添付ファイルの ID と名前のみが返され、サイズは返されません。しかし、ユーザーがそれらをダウンロードするかどうかを決定できるように、それらを知る必要があります。どうすればこの情報を入手できますか?
サーバーへの SOAP リクエストを作成するコードを次に示します。
+(NSString*) syncFolderItems:(NSString*)folderID :(NSString*) syncState
{
NSString * syncStateStr=@"<SyncState>%@</SyncState>";
if(syncState!=nil && ![syncState isEqualToString:@""])
{
syncStateStr=[NSString stringWithFormat:syncStateStr,syncState];
}
else
syncStateStr=@"";
NSString * request= @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
"<soap:Body>"
"<SyncFolderItems xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\">"
"<ItemShape>"
"<t:BaseShape>IdOnly</t:BaseShape>"
"</ItemShape>"
"<SyncFolderId>"
"<t:FolderId Id=\"%@\"/>"
"</SyncFolderId>"
"%@"
"<MaxChangesReturned>10</MaxChangesReturned>"
"</SyncFolderItems>"
"</soap:Body>"
"</soap:Envelope>";
return [NSString stringWithFormat:request, folderID,syncStateStr];
}
+(NSString*)getMailItemsDetails:(NSMutableArray*)items
{
NSString *request =
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
"<soap:Body>"
"<GetItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\">"
"<ItemShape>"
"<t:BaseShape>Default</t:BaseShape>"
"<t:IncludeMimeContent>false</t:IncludeMimeContent>"
"<t:AdditionalProperties>"
"<t:FieldURI FieldURI=\"item:Attachments\"/>"
"</t:AdditionalProperties>"
"</ItemShape>"
"<ItemIds>"
"%@"
"</ItemIds>"
"</GetItem>"
"</soap:Body>"
"</soap:Envelope>";
NSString *itemIdTemplate = @"<t:ItemId Id=\"%@\" />";
NSString *itemsIds = @"";
for(NSString *msgID in items)
{
NSString *itemId = [NSString stringWithFormat:itemIdTemplate, msgID];
itemsIds = [itemsIds stringByAppendingString:itemId];
}
return [NSString stringWithFormat:request, itemsIds];
}
何か不足していますか?(追加のプロパティがあるかもしれません?) 別のリクエストを使用する必要がありますか? EWSリクエストでそのようなことは可能ですか?そうでない場合、問題を解決するための回避策はありますか? どんな助けでも大歓迎です。