Q:

how to create text image on the fly and embed it with email

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);

A:

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.