i have to do the following: my documents are stored on a server. The only path i'm getting is an URI I was trying to get the document but i'm keep getting a "403 Forbidden".
string[] myArray = context.Request.QueryString["ItemsArray"].Split(',');
MailMessage m = new MailMessage(new MailAddress("bart@schelkens.be"),
new MailAddress("bart@schelkens.be")
);
m.Subject = "Emailing documents";
foreach (string path in myArray)
{
using (WebClient wb = new WebClient())
{
wb.UseDefaultCredentials = false;
wb.Credentials = new NetworkCredential(_userName, _passWord);
var stream = wb.OpenRead(path);
m.Attachments.Add(new Attachment(stream, ""));
}
}
string mailBody = "Dear<BR/> Please find attached a new version of the documents.";
mailBody += "<BR/>";
m.Body = mailBody;
m.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("hybrid.kaneka.be");
smtp.EnableSsl = false;
smtp.Send(m);
Or is there another way to get my document from the website and then mail it?
In SharePoint I created my own button which, using a js-file, goes to my ashx to mail my documents.