Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ComplexProperties/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,19 @@ internal void InternalLoad(BodyType? bodyType, IEnumerable<PropertyDefinitionBas
additionalProperties);
}

/// <summary>
/// Load the attachment.
/// </summary>
/// <param name="bodyType">Type of the body.</param>
/// <param name="additionalProperties">The additional properties.</param>
internal async System.Threading.Tasks.Task InternalLoadAsync(BodyType? bodyType, IEnumerable<PropertyDefinitionBase> additionalProperties)
{
await this.service.GetAttachmentAsync(
this,
bodyType,
additionalProperties);
}

/// <summary>
/// Validates this instance.
/// </summary>
Expand All @@ -326,5 +339,13 @@ public void Load()
{
this.InternalLoad(null, null);
}

/// <summary>
/// Loads the attachment. Calling this method results in a call to EWS.
/// </summary>
public async System.Threading.Tasks.Task LoadAsync()
{
await this.InternalLoadAsync(null, null);
}
}
}
47 changes: 44 additions & 3 deletions ComplexProperties/FileAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ public void Load(Stream stream)
}
}

/// <summary>
/// Loads the content of the file attachment into the specified stream. Calling this method results in a call to EWS.
/// </summary>
/// <param name="stream">The stream to load the content of the attachment into.</param>
public async System.Threading.Tasks.Task LoadAsync(Stream stream)
{
this.loadToStream = stream;

try
{
await this.LoadAsync();
}
finally
{
this.loadToStream = null;
}
}

/// <summary>
/// Loads the content of the file attachment into the specified file. Calling this method results in a call to EWS.
/// </summary>
Expand All @@ -224,6 +242,29 @@ public void Load(string fileName)
this.contentStream = null;
}

/// <summary>
/// Loads the content of the file attachment into the specified file. Calling this method results in a call to EWS.
/// </summary>
/// <param name="fileName">The name of the file to load the content of the attachment into. If the file already exists, it is overwritten.</param>
public async System.Threading.Tasks.Task LoadAsync(string fileName)
{
this.loadToStream = new FileStream(fileName, FileMode.Create);

try
{
await this.LoadAsync();
}
finally
{
this.loadToStream.Dispose();
this.loadToStream = null;
}

this.fileName = fileName;
this.content = null;
this.contentStream = null;
}

/// <summary>
/// Gets the name of the file the attachment is linked to.
/// </summary>
Expand Down Expand Up @@ -258,7 +299,7 @@ internal Stream ContentStream
set
{
this.ThrowIfThisIsNotNew();

this.contentStream = value;
this.content = null;
this.fileName = null;
Expand All @@ -278,7 +319,7 @@ public byte[] Content
internal set
{
this.ThrowIfThisIsNotNew();

this.content = value;
this.fileName = null;
this.contentStream = null;
Expand All @@ -290,7 +331,7 @@ internal set
/// </summary>
public bool IsContactPhoto
{
get
get
{
EwsUtilities.ValidatePropertyVersion(this.Service, ExchangeVersion.Exchange2010, "IsContactPhoto");

Expand Down
Loading