Note that there are some explanatory texts on larger screens.

plurals
  1. PONull cannot be for 'stream'
    text
    copied!<p>I keep getting an exception everytime i try to display an image in an emailbody of the project im currently doing. It is retrieving image in a sharepoint picture library to be displayed as an attachment. This is my code and i am having errors on line 264 which is currently calling the method.</p> <pre><code> if (txtEventPictureURL.Text != "") { string siteurl = "http://it3127:30091"; string filename = txtEventPictureURL.Text; System.Drawing.Image imgForCallOut = Image.FromStream(GetImageforCharts(siteurl, filename)); //LINE 264 ERROR mailItem.HTMLBody = Environment.NewLine + @"&lt;html&gt;Event Title : " + txtTitle.Text + Environment.NewLine + "Event Description : " + txtDescription.Text + Environment.NewLine + " Event Start Date From :" + dtpStartDate.Text + " To " + dtpEndDate.Text + Environment.NewLine + "Time From : " + cbStartHours.Text + " : " + cbStartMins.Text + " To " + cbEndHours.Text + " : " + cbEndMins.Text + "Image : " + "&lt;img src=" + imgForCallOut + " /&gt; &lt;/html&gt;"; //var doc = global.ThisAddIn.Application.ActiveWindow().WordEditor; //var pic = doc.Application.Selection.InlineShapes.AddPicture("MY IMAGE URL", true); //doc.Application.Selection.Hyperlinks.add(pic, "MY URL"); } } public static MemoryStream GetImageforCharts(string siteUrl, string fileName) { Byte[] fileContentsArray = null; MemoryStream imageStream = null; //siteUrl = "http://it3127:30091/"; try { using (SPSite site = new SPSite(siteUrl)) // using (SPSite site = SPContext.Current.Site) { using (SPWeb web = site.OpenWeb()) { SPPictureLibrary chartPictureLibrary = (SPPictureLibrary)web.Lists["Pictures"]; SPQuery query = new SPQuery(); query.Query = @"&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name ='Title'/&gt;&lt;Value Type='Text'&gt;" + fileName + "&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;"; SPListItemCollection lstImages = chartPictureLibrary.GetItems(query); foreach (SPListItem r in lstImages) { SPFile file = r.File; using (Stream fileContents = file.OpenBinaryStream()) { long length = fileContents.Length; fileContentsArray = new Byte[length]; fileContents.Read(fileContentsArray, 0, Convert.ToInt32(length)); } } } } imageStream = new MemoryStream(fileContentsArray); return imageStream; } catch (Exception ex) { return null; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload