EwsDeleteAttachment Method
Deletes the attachment with the specified filename from the specified item.

Namespace: MailBee.EwsMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public int DeleteAttachment(
	ItemId id,
	string filenameOrAttachId,
	bool isAttachId,
	bool deleteFirstOccurenceOnly
)

Parameters

id
Type: ItemId
The ID of the item. Null reference (Nothing in Visual Basic) not allowed.
filenameOrAttachId
Type: SystemString
The filename or string ID of the attachment to delete. Null reference or empty string not allowed.
isAttachId
Type: SystemBoolean
If true, filenameOrAttachId is treated as ID; otherwise, filename.
deleteFirstOccurenceOnly
Type: SystemBoolean
if true, only the first occurrence of the attachment with the given filename will be removed; otherwise, all occurrences. Ignored if filenameOrAttachId is true (multiple attachments cannot have the same ID).

Return Value

Type: Int32
Number of attachments removed, or zero if no attachments with the given filename or ID found, or -1 on error (if ThrowExceptions is false).
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
NotImplementedExceptionThe .NET runtime is .NET Core.
Remarks

The attachment will be deleted permanently.

There can be multiple attachements with the same filename. With this method you can delete them all or only the first one.

Note Note
The method does not cause an exception in case if no attachment with the given filename or attachment ID is found (you'll simly get zero as the return value). Providing incorrect item ID, however, is considered error.

If you need more sophisticated processing of an item, you can use NativeItem property to access its members and then call UpdateItem(EwsItem) to save the changes to the MS Exchange server.

Note Note
This method is not implemented in .NET Core. Use DeleteAttachmentAsync(ItemId, String, Boolean, Boolean) instead.
See Also