MapiAttachmentCollection.Add

Add(string, MapiMessage)

Adds the new attachment as embedded message.

public void Add(string name, MapiMessage msg)
ParameterTypeDescription
nameStringThe name of attachment.
msgMapiMessageThe MapiMessage that represents the attached message.

Exceptions

exceptioncondition
ArgumentNullExceptionthrows if message is null.

See Also


Add(string, byte[])

Adds the new attachment.

public void Add(string name, byte[] data)
ParameterTypeDescription
nameStringThe name of attachment.
dataByte[]The attachment data.

Exceptions

exceptioncondition
ArgumentNullExceptionthrows if attachment name is null or empty.
ArgumentNullExceptionthrows if attachment data is null.

See Also


Add(string, ReferenceAttachmentOptions)

Adds a reference attachment to the collection using the specified name and configuration options.

public void Add(string name, ReferenceAttachmentOptions options)
ParameterTypeDescription
nameStringThe name of the attachment to display in the message.
optionsReferenceAttachmentOptionsAn instance of ReferenceAttachmentOptions containing the configuration details for the reference attachment, such as the shared link, URL, and provider name.

Exceptions

exceptioncondition
ArgumentNullExceptionThrown if options is null.

Remarks

This method adds a reference attachment to the message and applies additional properties based on the provided ReferenceAttachmentOptions object. The additional properties include permission type, original permission type, folder indicator, provider endpoint URL, preview URL, and thumbnail URL.

Examples

The following example demonstrates how to use this method in C#:

[C#]

var options = new ReferenceAttachmentOptions(
    "https://drive.google.com/file/d/1HJ-M3F2qq1oRrTZ2GZhUdErJNy2CT3DF/",
    "https://drive.google.com/drive/my-drive",
    "GoogleDrive"
)
{
    PermissionType = AttachmentPermissionType.AnyoneCanEdit,
    OriginalPermissionType = 0,
    IsFolder = false
};

msg.Attachments.Add("Document.pdf", options);

The following example demonstrates how to use this method in Visual Basic:

[Visual Basic]

Dim options As New ReferenceAttachmentOptions(
    "https://drive.google.com/file/d/1HJ-M3F2qq1oRrTZ2GZhUdErJNy2CT3DF/",
    "https://drive.google.com/drive/my-drive",
    "GoogleDrive"
)
options.PermissionType = AttachmentPermissionType.AnyoneCanEdit
options.OriginalPermissionType = 0
options.IsFolder = False

msg.Attachments.Add("Document.pdf", options)

See Also


Add(MapiAttachment)

Adds an object to the end of the Collection.

public void Add(MapiAttachment item)
ParameterTypeDescription
itemMapiAttachmentThe object to be added to the end of the Collection. The value can be null for reference types.

See Also