Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My application is already sending email with embedded image, but this time the images were all stored in a database.
I can't figure it out on how to read and process the stored image to be part of the email.

Thanks in advance

What I have tried:

below code is for reading image from file path.

using (FileStream fileStream = new FileStream(Server.MapPath("~/" + fname), FileMode.Open, FileAccess.Read))
{
  content = new byte[fileStream.Length];
  fileStream.Read(content, 0, content.Length);
}

fileAttach.Content = content;

                CreateAttachmentType attachmentRequest = new CreateAttachmentType();
                attachmentRequest.Attachments = new AttachmentType[1];
                attachmentRequest.Attachments[0] = fileAttach;
                attachmentRequest.Attachments[0].IsInline = true;
                attachmentRequest.Attachments[0].ContentId = FileName;
                attachmentRequest.ParentItemId = emailResponseMessage.Items.Items[0].ItemId;
Posted
Updated 14-Feb-19 12:19pm
Comments
Richard MacCutchan 14-Feb-19 4:01am    
The same as above, read the image data from the database into the content field.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900