
These are sent as attachments and are represented as Attachment instances. In addition to the body, you might want to send additional files. All messages include a Body, which contains the content of the message. The Attachment class is used with the MailMessage class. Display the values in the ContentDisposition for the attachment.ĬontentDisposition^ cd = data->ContentDisposition Ĭonsole::WriteLine( L"Content disposition" ) Ĭonsole::WriteLine( L"File ", d.Key, d.Value) Add credentials if the SMTP server requires them.Ĭlient->Credentials = CredentialCache::DefaultNetworkCredentials SmtpClient^ client = gcnew SmtpClient( server ) Add the file attachment to this email message. Add time stamp information for the file.ĬontentDisposition^ disposition = data->ContentDisposition ĭisposition->CreationDate = System::IO::File::GetCreationTime( file ) ĭisposition->ModificationDate = System::IO::File::GetLastWriteTime( file ) ĭisposition->ReadDate = System::IO::File::GetLastAccessTime( file ) Create the file attachment for this email message.Īttachment^ data = gcnew Attachment(file, MediaTypeNames::Application::Octet) MailMessage^ message = gcnew MailMessage( data report.",L"See the attached spreadsheet." ) Create a message and set up the recipients. This example assumes that a file named Data.xls exists in the
:max_bytes(150000):strip_icc()/homeselectedemail-5c942774c9e77c00018fb67d.jpg)
Specify the file to be attached and sent. static void CreateMessageWithAttachment( String^ server )


#TEFVIEW SEND AS ATTACHMENT CODE#
The following code example demonstrates attaching a file to an email message.
