Hi there
Wonder if you can help me, I have the following code:
SqlCommand[] sqlQuery = new SqlCommand[10];
Byte[] data = new Byte[10];
MemoryStream[] stream = new MemoryStream[10];
LinkedResource[] logo = new LinkedResource[10];
if (m.Count > 0)
{
int i = 0;
foreach (Match m1 in m)
{
sqlQuery[i] = new SqlCommand("SELECT Data FROM Attachments WHERE (fileName='" + getImageF + "')", myConnection1);
data = (byte[])sqlQuery[i].ExecuteScalar();
stream[i] = new MemoryStream(data);
logo[i] = new LinkedResource(stream[i], "image/jpeg");
logo[i].ContentType.MediaType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
logo[i].ContentId = "image"+i.ToString();
emailBody1 = HTMLContent.Replace(m1.Value, "<img src='cid:image" + i.ToString() + "'>");
htmlView.LinkedResources.Add(logo[i]);
i++;
myConnection1.Close();
}
}
Can someone please help me in makeing this more efficient i.e. get rid of the hardcoded value of 10 (redim it)
The reason, why i placed 10 is that, I dont know how to redim the code, I've seen many example, but dont know how to incorporate it with the code above
Many thanks
Mousemat24
Our community of experts have been thoroughly vetted for their expertise and industry experience.