发送图片邮件
构建content时,img标签里面的cid是什么
构建content时,img标签里面的cid是什么
2019-06-23
public void img(String to, String subject, String text, String file,String rcid) throws MessagingException { MimeMessage mm = sender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(mm,true); helper.setFrom(from); helper.setTo(to); helper.setSubject(subject); String content = text+"<img src = \'cid:"+rcid+"\'>"; helper.setText(content,true); FileSystemResource fileSystemResource = new FileSystemResource(new File(file)); helper.addInline(rcid,fileSystemResource); sender.send(mm);}//注:①cid这行代码中的\'不能缺少;//②setText()方法要放在addInline()方法之前,否则图片不能正常显示。
举报