Get Attachement From Sharepoint list
foreach (String attachmentname in tempEmpCerificationitem.Attachments)
{
Stream stream;
ct.TemAttachmentName = attachmentname;
String attachmentAbsoluteURLs = tempEmpCerificationitem.Attachments.UrlPrefix + attachmentname; // gets the containing directory URL
// To get the SPSile reference to the attachment just use this code
SPFile attachmentFile = ct.oweb.GetFile(attachmentAbsoluteURLs);
// To read the file content simply use this code
ct.stream= attachmentFile.OpenBinaryStream();
StreamReader reader = new StreamReader(ct.stream);
String fileContent = reader.ReadToEnd();
ct.Attachment = attachmentAbsoluteURLs.ToString();
}
Comments