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

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


Type: ItemId
The ID of the item. Null reference (Nothing in Visual Basic) not allowed.
Type: SystemString
The filename or string ID of the attachment to delete. Null reference or empty string not allowed.
Type: SystemBoolean
If true, filenameOrAttachId is treated as ID; otherwise, filename.
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).
MailBeeExceptionAn error occurred and ThrowExceptions is true.

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.

See Also