简体   繁体   English

在图像上写邮件内容,并在EMAIL中将图像作为正文发送

[英]Write Mail content on an image and send image as a body in EMAIL

We send mails to registered user from our application using the below mentioned code in Java. 我们使用以下Java代码从我们的应用程序向注册用户发送邮件。

However mail received by them turns out to be very simple and hence we need to edit it. 但是,他们收到的邮件非常简单,因此我们需要对其进行编辑。

I need to write the same content to an image background and then transmit this image as an e-mail to the users. 我需要将相同的内容写到图像背景,然后将该图像作为电子邮件发送给用户。

Is there a way out to achieve this purpose.We use SMTP transport to send messages. 有没有办法实现这一目的。我们使用SMTP传输来发送消息。

Code snippet shows the present way of writing contents to message. 代码段显示了将内容写入消息的当前方式。

String from = "blah@abc.com";
String to[] = new String[]{variable};
String subject = "Subject";

StringBuffer content = new StringBuffer();
        content.append("");
        content.append("");
        content.append("");
        content.append(variable);

Is there a way out to write all the stuff on an pre identified image and then send this image as the body of the email. 是否有办法将所有内容写在预先标识的图像上,然后将该图像作为电子邮件的正文发送。

These answers will tell you how to put an image into an email message: 这些答案将告诉您如何将图像放入电子邮件中:

  1. Adding image to email via Java mail 通过Java邮件将图像添加到电子邮件
  2. Sending mail along with embedded image using javamail 使用javamail发送邮件以及嵌入式图像
  3. Inline images in email using JavaMail 使用JavaMail在电子邮件中内嵌图像

As for rendering the text of an email to an image. 至于将电子邮件的文本渲染为图像。 Either use some HTML viewer and have it render on a Graphics context you create, or determine the size of the image required (using Graphics ) and render onto the Graphics (agian) of a BufferedImage you create: 使用某些HTML查看器并使其在您创建的Graphics上下文中呈现,或者确定所需图像的大小(使用Graphics )并呈现在您创建的BufferedImageGraphics (agian)上:

BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
img.getGraphics()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM