The problem is that the content of byte.eml
is not a base64 encoded image, it is a MIME document.
You need to parse the MIME document and then get your image.
You can google "C# MIME MAIL PARSING".
Here is a related SO question to get you started
UPDATE:
Ok, so let's assume that you actually do have a valid representation of an image as a base64 string...
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim bytes As Byte() = File.ReadAllBytes(Server.MapPath("Chrysanthemum.jpg"))
Dim base64 As String = Convert.ToBase64String(bytes)
'' base64 is what you say you have
Dim newBytes As Byte() = Convert.FromBase64String(base64)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "image/jpeg"
Response.BinaryWrite(newBytes)
Response.End()
End Sub
</script>
This code works, if you substitute the text you have for base64
and it doesn't work, you have not a valid base64 string representation of an image.
Update 2:
This will read the text file that you say contains base64 and write it to the response.
If it still does not work then you have another question to ask:
How do I properly extract a base64 section from a MIME email?
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim base64 As String = File.ReadAllText("E:\mailbox\P3_hemantd.mbx\byte.eml")
Dim newBytes As Byte() = Convert.FromBase64String(base64)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "image/jpeg"
Response.BinaryWrite(newBytes)
Response.End()
End Sub
</script>