Class AttachmentCollectionExtensions
- Namespace
- Wolfgang.Extensions.Mail
- Assembly
- Wolfgang.Extensions.Mail.dll
A collection of extension methods for the AttachmentCollection class.
public static class AttachmentCollectionExtensions
- Inheritance
-
AttachmentCollectionExtensions
- Inherited Members
Methods
AddRange(AttachmentCollection, IEnumerable<Attachment>)
Adds a range of Attachment objects to the AttachmentCollection.
public static void AddRange(this AttachmentCollection source, IEnumerable<Attachment> attachments)
Parameters
sourceAttachmentCollectionThe collection to add to
attachmentsIEnumerable<Attachment>The list of Attachment to add
Exceptions
- ArgumentNullException
source is null
- ArgumentNullException
attachments is null
AddRange(AttachmentCollection, IEnumerable<string>)
Adds a range of Attachment objects to the AttachmentCollection.
public static void AddRange(this AttachmentCollection source, IEnumerable<string> fileNames)
Parameters
sourceAttachmentCollectionThe collection to add to
fileNamesIEnumerable<string>The list of string containing file names to add
Exceptions
- ArgumentNullException
source is null
- ArgumentNullException
fileNames is null
AddRange(AttachmentCollection, params Attachment[])
Adds a range of Attachment objects to the AttachmentCollection.
public static void AddRange(this AttachmentCollection source, params Attachment[] attachments)
Parameters
sourceAttachmentCollectionThe collection to add to
attachmentsAttachment[]The list of Attachment to add
Exceptions
- ArgumentNullException
source is null
- ArgumentNullException
attachments is null
AddRange(AttachmentCollection, params string[])
Adds a range of Attachment objects to the AttachmentCollection.
public static void AddRange(this AttachmentCollection source, params string[] fileNames)
Parameters
sourceAttachmentCollectionThe collection to add to
fileNamesstring[]The list of string containing file names to add
Exceptions
- ArgumentNullException
source is null
- ArgumentNullException
fileNames is null
ExceedsLimit(AttachmentCollection, long)
Returns a value indicating whether the total size of all attachments exceeds the specified maximum number of bytes.
public static bool ExceedsLimit(this AttachmentCollection source, long maxBytes)
Parameters
sourceAttachmentCollectionThe AttachmentCollection to check.
maxByteslongThe maximum allowed total size in bytes.
Returns
- bool
trueif the total attachment size exceedsmaxBytes; otherwise,false.
Exceptions
- ArgumentNullException
sourceis null.
TotalSize(AttachmentCollection)
Returns the total size in bytes of all attachments in the AttachmentCollection whose underlying streams support seeking. Non-seekable streams are excluded from the total.
public static long TotalSize(this AttachmentCollection source)
Parameters
sourceAttachmentCollectionThe AttachmentCollection to measure.
Returns
- long
The total size in bytes of all seekable attachment streams.
Examples
using var message = new MailMessage();
message.Attachments.AddRange("report.pdf", "data.csv");
long totalBytes = message.Attachments.TotalSize();
Exceptions
- ArgumentNullException
sourceis null.