Add-MapiAttach

Description

Adds an attachment to a message from a byte array, stream, or file.  Properties of the new attachment object can be added or modified using Add-MapiProp and Set-MapiProp.

Syntax
Add-MapiAttach  
 -MessageMapiObject<Mapi.Net.Message>
 -DataByte[]
(optional)-AttachMethodMapi.NET.Flags.PR_ATTACH_METHOD
(optional)-AttachmentNumberInt32
Add-MapiAttach  
 -MessageMapiObject<Mapi.Net.Message>
 -DataStreamSystem.IO.Stream
(optional)-AttachMethodMapi.NET.Flags.PR_ATTACH_METHOD
(optional) -AttachmentNumberInt32
Add-MapiAttach  
 -MessageMapiObject<Mapi.Net.Message>
 -FileNameString
(optional)-AttachMethodMapi.NET.Flags.PR_ATTACH_METHOD
(optional)-AttachmentNumberInt32
Parameters
MessageA message object.  Use Get-MapiItem to get an instance of this object
DataAn array of bytes to be saved as the attachment data
DataStreamA .NET stream from which the data is copied to the attachment object on the message
FileNameA valid path to a file.  The 'Filename' and 'LongFileName' attributes of the new attachment are populated from the filename of the selected file
AttachMethodOne of the Enum values from Mapi.NET.Flags.PR_ATTACH_METHOD
Note: ATTACH_BY_VALUE is the default and is used if this parameter is not explicitly set
  • ATTACH_BY_REF_ONLY
  • ATTACH_BY_REF_RESOLVE
  • ATTACH_BY_REFERENCE
  • ATTACH_BY_VALUE
  • ATTACH_EMBEDDED_MSG
  • ATTACH_OLE
  • NO_ATTACHMENT
AttachmentNumber

The index number of the attachment.  This value controls the order in which attachments are rendered in the visible attachment list of a message.

By default, this value is set to -1, which causes the attachment to be added to the end of the list of attachments.