GetAttachmentType 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
类 GetAttachmentType 表示获取 Exchange 数据库中某个项的附加项和文件的请求。
public ref class GetAttachmentType : ExchangeWebServices::BaseRequestType
public class GetAttachmentType : ExchangeWebServices.BaseRequestType
Public Class GetAttachmentType
Inherits BaseRequestType
- 继承
示例
下面的代码示例演示了两个附件的获取附件请求。
static void GetAttachment(ExchangeServiceBinding esb)
{
// Create the request.
<span class="label">GetAttachmentType</span><span class="label">request</span> = new GetAttachmentType();
// Create the response shape.
AttachmentResponseShapeType responseShape = new AttachmentResponseShapeType();
responseShape.BodyType = BodyTypeResponseType.Text;
responseShape.BodyTypeSpecified = true;
// Add the response shape to the request.
<span class="label">request</span>.AttachmentShape = responseShape;
// Identify the attachment IDs to get.
RequestAttachmentIdType[] ids = new RequestAttachmentIdType[2];
ids[0] = new RequestAttachmentIdType();
ids[1] = new RequestAttachmentIdType();
ids[0].Id = "AAAlAE1BQG1";
ids[1].Id = "AAAlAE1Bas";
// Add the attachment IDs to the request.
<span class="label">request</span>.AttachmentIds = ids;
try
{
GetAttachmentResponseType response = esb.GetAttachment(<span class="label">request</span>);
ResponseMessageType[] rmta = response.ResponseMessages.Items;
foreach (ResponseMessageType responseMessage in rmta)
{
AttachmentInfoResponseMessageType airmt = (responseMessage as AttachmentInfoResponseMessageType);
AttachmentType[] attachments = airmt.Attachments;
// Type check for item or file attachment.
foreach (AttachmentType attachment in attachments)
{
if (attachment is FileAttachmentType)
{
FileAttachmentType fat = (attachment as FileAttachmentType);
// Assumes ASCII encoding.
string myContent = ASCIIEncoding.ASCII.GetString(fat.Content);
}
// Attachment is item attachment.
else
{
ItemAttachmentType iat = (attachment as ItemAttachmentType);
// TODO: Handle the item attachment.
}
}
}
}
catch (Exception x)
{
Console.WriteLine(x.Message);
}
}
注解
使用 GetItem 调用获取在 GetAttachment作中使用的附件标识符。
构造函数
| GetAttachmentType() |
构造 GetAttachmentType 函数初始化 类的新实例 GetAttachmentType 。 |
属性
| AttachmentIds |
属性 AttachmentIds 获取或设置在响应中返回的附件的标识符。 |
| AttachmentShape |
属性 AttachmentShape 获取或设置要为附件返回的其他属性。 |