?
Solved

Email Image from Byte Array

Posted on 2010-08-19
3
Medium Priority
?
446 Views
Last Modified: 2013-11-27
Hi to all,

I have an SQL 2005 database where I store thumbnails of my Item images. I need to email these images to some users using an automated process. I can't save the byte array to file to add this image as an attachment because of our security policy.

I was wondering if there is a way to email this image as a byte array to the user and then the user will be able to see the picture. Any suggestions would be appreciated.

I am using Visual Studio 2010 with .Net 4.0

Thanks in advance.
0
Comment
Question by:ALawrence007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 1000 total points
ID: 33475630
You can stuff your byte-array/image into a memorystream and use that to create the attachment
See http://www.systemnetmail.com/faq/3.4.2.aspx for an example.
Just make sure you set the correct MIME-type
0
 
LVL 8

Assisted Solution

by:bhmahler
bhmahler earned 1000 total points
ID: 33477460
If you can use HTML emails then you can add the image as a base64 image.  However, many email clients may interpret this as spam.  To do it would be something like this
Dim imgBytes As Byte() = GetYourBytesFromDB()
Dim b64Image As String = Convert.ToBase64String(imgBytes)

'Make sure you specify the proper image type
Dim imgHtml As String = "<img src=""data:image/png;base64," & b64Image & """ />"

'Or for C#

byte[] imgBytes = getBytesFromDb();
string b64String = Convert.ToBase64String(imgBytes);

string imgHtml = "<img src=\"data:image/png;base64," & b64Image & "\" />";

Open in new window

0
 

Author Closing Comment

by:ALawrence007
ID: 33478632
Thanks Guys!! I will actually be using Both Solutions!!!
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question