使用java将QRcode发送到电子邮件

使用java将QRcode发送到电子邮件,java,Java,我是否可以使用java直接将QRcode发送到电子邮件,而无需任何本地存储工作?下面的代码生成QRcode public static void createQRCode(String qrCodeData, String filePath, String charset, Map hintMap, int qrCodeheight, int qrCodewidth) throws WriterException, IOException { BitMatrix matrix = new Mul

我是否可以使用java直接将QRcode发送到电子邮件,而无需任何本地存储工作?下面的代码生成QRcode

public static void createQRCode(String qrCodeData, String filePath,
String charset, Map hintMap, int qrCodeheight, int qrCodewidth)
throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(
    new String(qrCodeData.getBytes(charset), charset),
    BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight, hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath
    .lastIndexOf('.') + 1), new File(filePath));
System.out.println("QR code encoded");
}

public static String readQRCode(String filePath, String charset, Map hintMap)
throws FileNotFoundException, IOException, NotFoundException {
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
    new BufferedImageLuminanceSource(
            ImageIO.read(new     FileInputStream(filePath)))));
Result qrCodeResult = new MultiFormatReader().decode(binaryBitmap,
    hintMap);
return qrCodeResult.getText();
}
我想将上面生成的QR附加到车身部分的下面代码,而不将其存储在本地。我正在使用eclipse火星。。请帮帮我

String from = USER_NAME;
String pass = PASSWORD;
String[] to = {RECIPIENT};
String subject = "Java mail example";
String body= "hi this is tetsting mail!";


Properties props = System.getProperties();
String host = "smtp.gmail.com";

props.put("mail.smtp.starttls.enable", "true");

props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.port", "587");
props.put("mail.smtp.auth", "true");


Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);

try {


message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];

// To get the array of addresses
for( int i = 0; i < to.length; i++ ) {
   toAddress[i] = new InternetAddress(to[i]);
}

for( int i = 0; i < toAddress.length; i++) {
   message.addRecipient(Message.RecipientType.TO, toAddress[i]);
}

message.setSubject(subject);
message.setText(body, "UTF-8", "html");

Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("Email Sent successfully");

}
catch (AddressException ae) {
ae.printStackTrace();
}
catch (MessagingException me) {
me.printStackTrace();
}
}
String from=用户名;
字符串pass=密码;
字符串[]to={RECIPIENT};
String subject=“Java邮件示例”;
String body=“嗨,这是一封邮件!”;
Properties props=System.getProperties();
String host=“smtp.gmail.com”;
props.put(“mail.smtp.starttls.enable”、“true”);
props.put(“mail.smtp.host”,host);
props.put(“mail.smtp.user”,from);
props.put(“mail.smtp.password”,pass);
props.put(“mail.smtp.port”,“587”);
props.put(“mail.smtp.auth”,“true”);
Session Session=Session.getDefaultInstance(props,null);
MimeMessage message=新MimeMessage(会话);
试一试{
message.setFrom(新的InternetAddress(from));
InternetAddress[]toAddress=新的InternetAddress[to.length];
//获取地址数组的步骤
for(int i=0;i
检查此项:应尝试将此二维码保存为图像,然后通过电子邮件发送,只需使用文件的#writeToStream即可