Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Attach the message string to this e-mail message.
- //var reader = new StreamReader(@"c:Temptelephone.txt");
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "telephone.txt");
- Attachment data = new Attachment(path, MediaTypeNames.Text.Plain);
- // Send textMessage as part of the e-mail body.
- message.Attachments.Add(data);
- ContentDisposition disposition = data.ContentDisposition;
- disposition.Inline = true;
- message.Attachments[0].ContentId = "telephone.txt";
- //Send the message.
- // Include credentials if the server requires them.
- SmtpClient client = new SmtpClient(server);
- client.Credentials = CredentialCache.DefaultNetworkCredentials;
- try
- {
- client.Send(message);
- }
- catch (Exception ex)
- {
- Console.WriteLine("Exception caught in CreateMessageInlineAttachment: {0}",
- ex.ToString());
- }
- data.Dispose();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement