我认为我们可以通过执行类似这样的代码创建一个文本图像并将其转换为 jpeg 文件,但是如何将此图像嵌入到邮件和发送中。感谢任何帮助
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);