Solved

Email Image from Byte Array

Posted on 2010-08-19
3
431 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks Guys!! I will actually be using Both Solutions!!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 109
How to read XML file attributes... 17 39
Trouble with References... 5 22
Hide Tab Page 3 18
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now