creating attachments for a new MailMessage()
So this is what I have written:
public static void SendMail(string sender, string to, string subject, string body, string attachment)
{
using (mailstuff.MailMessage message = new mailstuff.MailMessage())
{
message.IsBodyHtml = true;
message.From = new MailAddress(sender);
message.To.Add(to);
message.Subject = subject;
message.Body = body;
Attachment data = new Attachment(attachment, MediaTypeNames.Application.Octet );
message.Attachments.Add(data);
SmtpClient sClient = new SmtpClient();
//host and credentials can be found in webconfig so no need
sClient.Send(message);
}
}
but it does not compile. It says:
Error 1 The name 'MediaTypeNames' does not exist in the current context
I was following the msdn example here:
http://msdn2.microsoft.com/en-us/library/system.net.mail.attachment.aspx
What am I doing wrong?
I already included System.Net.Mail in using. (mailstuff is: using mailstuff = System.Net.Mail)
Also the method works fine if I comment the part regarding attachments.
Thank you in advance.

