I am trying to attach a file present in a doc library and send it using smtp in client object model. Its in office 365. It throws an exception "The given path's format is not supported". Is there any workaround?
SmtpClient client = new SmtpClient();
client.Port = 587;
client.EnableSsl = true;
client.Host = "smtp.office365.com";
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("username", "password");
MailMessage mm = new MailMessage("sender", "reciever", "title", "body");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment("url");// url of the file present in document library
mm.Attachments.Add(attachment);`