Avatar of mousemat24
mousemat24

asked on 

URI formats are not supported - trying get get an image thats held in a SQL field

Hi there

Wonder if you can help me?

I'm using C#, and want to send an email out to users using SMTP, the data will come from SQL, and images will be uploaded to a SQL table. When the email is sent to the users it must contain the data from SQL table, but also, it must display the image in the email (as I said, the image is held in a SQL table - image field in SQL)

The problem I'm having is on this line in my SMTP code

LinkedResource logo = new LinkedResource(<ERROR>);

"URI formats are not supported."

How do I display an image, thats stored in a SQL image field. Please note, I cant upload the file to the server.

Thanks
Mousemat24

.NET Programming

Avatar of undefined
Last Comment
Die-Tech
ASKER CERTIFIED SOLUTION
Avatar of Die-Tech
Die-Tech

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of mousemat24
mousemat24

ASKER

Thanks Die-Tech

Ok, so if I have an image on my c:\ i.e.

c:\logo.jpg

What would my code be to get it streamed across?

Thanks
Avatar of mousemat24
mousemat24

ASKER

sorry that was a bad example i.e. c:\logo.jpg

I mean if i get the image, how would i place that as a stream?
Avatar of Die-Tech
Die-Tech

You could use a FileStream in that case; however, the LinkedResource class has a constructor that accepts the file name.  All it does internally is create a stream that it passes to the other constructor, but it's one less step you have to do.

string fileName = @"c:\logo.jpg";
LinkedResource logo = new LinkedResource(fileName);
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo