Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:36:43+00:00 2026-06-09T20:36:43+00:00

I think we can create a text image and convert it to jpeg file

  • 0

I think we can create a text image and convert it to jpeg file by doing some code like this but how to embed this image with mail and send.any help is appreciated

string Text = HttpContext.Current.Request.QueryString["Text"]; 
Color FontColor = Color.Blue; 
Color BackColor = Color.White; 
String FontName = "Times New Roman"; 
int FontSize = 10; 
int Height = 150; 
int Width = 150;

Bitmap bitmap = new Bitmap(Width, Height); 
Graphics graphics = Graphics.FromImage(bitmap); 
Color color = Color.Gray; 
System.Drawing.Font font = new System.Drawing.Font(FontName, FontSize);
PointF point = new PointF(5.0F, 5.0F); 

SolidBrush BrushForeColor = new SolidBrush(FontColor);
SolidBrush BrushBackColor = new SolidBrush(BackColor);
Pen BorderPen = new Pen(color); 

System.Drawing.Rectangle displayRectangle = new System.Drawing.Rectangle(new Point(0, 0), new Size(Width - 1, Height - 1));
graphics.FillRectangle(BrushBackColor, displayRectangle);
graphics.DrawRectangle(BorderPen, displayRectangle);
StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
StringFormat format2 = new StringFormat(format1);
graphics.DrawString(Text, font, Brushes.Red, (RectangleF)displayRectangle, format2);

HttpContext.Current.Response.ContentType = "image/jpeg";
bitmap.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Jpeg);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:36:44+00:00Added an answer on June 9, 2026 at 8:36 pm

    The code sample below skips creating the message and adding the subject, body and addresses. It shows the code used to embed an image that is initially stored in a byte array. The key is to get your image into a memory stream.

    //... other System.Net.Mail.MailMessage creation code
    // CustomerSignature is a byte array containing the image
    System.IO.MemoryStream ms = new System.IO.MemoryStream(CustomerSignature);
    System.Net.Mime.ContentType contentType = new System.Net.Mime.ContentType();
    contentType.MediaType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
    contentType.Name = "signature.jpg";
    System.Net.Mail.Attachment imageAttachment = new System.Net.Mail.Attachment(ms, contentType);
    mailMessage.Attachments.Add(imageAttachment);
    System.Net.Mail.LinkedResource signature = new System.Net.Mail.LinkedResource(ms, "image/jpeg");
    signature.ContentId = "CustomerSignature";
    System.Net.Mail.AlternateView aView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(mailMessage.Body, new System.Net.Mime.ContentType("text/html"));
    aView.LinkedResources.Add(signature);
    mailMessage.AlternateViews.Add(aView);
    

    I had issues where the embedded image was shown in some email programs, and not others. I modified the line that creates the linked resource, and the line that creates the new AlternativeView and the image is now viewable across a wider range of programs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a file that embeds an image as text within some
I think the following code can be used to create manipulators. #include<iostream> ostream &
how can i create menu like this.??? Thank you.
I can think of lots of ways to do this on my own, but
Hi all I am having some problems that I think can be attributed to
I think it will be very hard for you to read the code but
I'm trying to convert an NFO file with some crazy high ASCII arts using
According to this site http://www.searchable-pdf.com/content.php?lang=en&c=61 , a PDF can be searchable when a text
I have checked many of other questions involving issues like this, but none have
If I have a button like the one in this image : http://www.freeimagehosting.net/image.php?4cd775814c.png how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.