Solved

Email Image from Byte Array

Posted on 2010-08-19
3
439 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
3 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 250 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 250 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal reports vb.net 2 39
Regular expression help 2 22
ASP/VB email question 4 31
Get distinct values from excel or comm seperated file 4 23
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’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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