MailMessage.AttachData Method (String, String, String)
Attach the contents of a string to the current message.
[Visual Basic]
Overloads Public Function AttachData( _
ByVal buffer As String, _
ByVal contentName As String, _
ByVal contentType As String _
) As Boolean
[C#]
public bool AttachData(
string buffer,
string contentName,
string contentType
);
Parameters
- buffer
- A string that contains the data to be attached to the message.
- contentName
- A string argument which specifies a name for the data being attached to the message. This typically is used as a file
name by the mail client to store the data in.Note that if a file name is specified with a path, only the base file name
will be used.
- contentType
- A string argument which specifies the type of data being attached. The value must be a valid MIME content type. If the
buffer contains only text characters, then the content type will be specified as "text/plain". If the buffer contains
binary data, then the content type will be specified as "application/octet-stream", which is appropriate for any type of
data.
Return Value
This method returns a boolean value. If the method succeeds, the return value is true. If the method
fails, the return value is false. To get extended error information, check the value of the
LastError property.
Remarks
This implementation of the method should never be used to attach binary data to a message. If you need to attach binary
data, use the implementation of that accepts a byte array as the buffer parameter.
See Also