本文整理汇总了Java中javax.mail.internet.MimeMultipart.setSubType方法的典型用法代码示例。如果您正苦于以下问题:Java MimeMultipart.setSubType方法的具体用法?Java MimeMultipart.setSubType怎么用?Java MimeMultipart.setSubType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.mail.internet.MimeMultipart
的用法示例。
在下文中一共展示了MimeMultipart.setSubType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAttachMail
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
/**
* @Method: createAttachMail
* @Description: ����һ����������ʼ�
* @param session
* @return
* @throws Exception
*/
public static MimeMessage createAttachMail(String subject, String content, String filePath) throws Exception{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
if(recipients.contains(";")){
List<InternetAddress> list = new ArrayList<InternetAddress>();
String []median=recipients.split(";");
for(int i=0;i<median.length;i++){
list.add(new InternetAddress(median[i]));
}
InternetAddress[] address =list.toArray(new InternetAddress[list.size()]);
message.setRecipients(Message.RecipientType.TO,address);
}else{
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
}
message.setSubject(subject);
MimeBodyPart text = new MimeBodyPart();
text.setContent(content, "text/html;charset=UTF-8");
MimeBodyPart attach = new MimeBodyPart();
DataHandler dh = new DataHandler(new FileDataSource(filePath));
attach.setDataHandler(dh);
attach.setFileName(dh.getName());
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(text);
mp.addBodyPart(attach);
mp.setSubType("mixed");
message.setContent(mp);
message.saveChanges();
return message;
}
示例2: createImageMail
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
/**
* @Method: createImageMail
* @Description: ����һ���ʼ����Ĵ�ͼƬ���ʼ�
* @param session
* @return
* @throws Exception
*/
public static MimeMessage createImageMail(String subject, String content, String imagePath) throws Exception {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
if(recipients.contains(";")){
List<InternetAddress> list = new ArrayList<InternetAddress>();
String []median=recipients.split(";");
for(int i=0;i<median.length;i++){
list.add(new InternetAddress(median[i]));
}
InternetAddress[] address =list.toArray(new InternetAddress[list.size()]);
message.setRecipients(Message.RecipientType.TO,address);
}else{
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
}
message.setSubject(subject);
MimeBodyPart text = new MimeBodyPart();
text.setContent(content, "text/html;charset=UTF-8");
MimeBodyPart image = new MimeBodyPart();
DataHandler dh = new DataHandler(new FileDataSource(imagePath));
image.setDataHandler(dh);
image.setContentID("xxx.jpg");
MimeMultipart mm = new MimeMultipart();
mm.addBodyPart(text);
mm.addBodyPart(image);
mm.setSubType("related");
message.setContent(mm);
message.saveChanges();
return message;
}
示例3: createMixedMail
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
/**
* @Method: createMixedMail
* @Description: ����һ��������ʹ�ͼƬ���ʼ�
* @param session
* @return
* @throws Exception
*/
public static MimeMessage createMixedMail(String subject, String content, String imagePath, String filePath) throws Exception {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
if(recipients.contains(";")){
List<InternetAddress> list = new ArrayList<InternetAddress>();
String []median=recipients.split(";");
for(int i=0;i<median.length;i++){
list.add(new InternetAddress(median[i]));
}
InternetAddress[] address =list.toArray(new InternetAddress[list.size()]);
message.setRecipients(Message.RecipientType.TO,address);
}else{
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
}
message.setSubject(subject);
MimeBodyPart text = new MimeBodyPart();
text.setContent(content,"text/html;charset=UTF-8");
MimeBodyPart image = new MimeBodyPart();
image.setDataHandler(new DataHandler(new FileDataSource(imagePath)));
image.setContentID("aaa.jpg");
MimeBodyPart attach = new MimeBodyPart();
DataHandler dh = new DataHandler(new FileDataSource(filePath));
attach.setDataHandler(dh);
attach.setFileName(dh.getName());
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(text);
mp.addBodyPart(image);
mp.setSubType("related");
MimeBodyPart bodyContent = new MimeBodyPart();
bodyContent.setContent(mp);
message.saveChanges();
return message;
}
示例4: makeEmail
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
private MimeMessage makeEmail(TokenData data, _EmailTemplate template, List<_BridgeMessageContent> contents, boolean allowReply) throws MessagingException, IOException {
MimeMultipart body = new MimeMultipart();
body.setSubType("alternative");
for (_BridgeMessageContent content : contents) {
MimeMultipart contentBody = new MimeMultipart();
contentBody.setSubType("related");
Optional<_EmailTemplateContent> contentTemplateOpt = template.getContent(content.getMime());
if (!contentTemplateOpt.isPresent()) {
continue;
}
_EmailTemplateContent contentTemplate = contentTemplateOpt.get();
contentBody.addBodyPart(makeBodyPart(data, contentTemplate, content));
if (contentTemplate.getContent().contains(EmailTemplateToken.SenderAvatar.getToken()) &&
data.getSenderAvatar() != null && data.getSenderAvatar().isValid()) {
log.info("Adding avatar for sender");
MimeBodyPart avatarBp = new MimeBodyPart();
_MatrixContent avatar = data.getSenderAvatar();
String filename = avatar.getFilename().orElse("unknown." + avatar.getType().replace("image/", ""));
avatarBp.setContent(avatar.getData(), avatar.getType());
avatarBp.setContentID("<" + senderAvatarId + ">");
avatarBp.setDisposition("inline; filename=" + filename + "; size=" + avatar.getData().length + ";");
contentBody.addBodyPart(avatarBp);
}
MimeBodyPart part = new MimeBodyPart();
part.setContent(contentBody);
body.addBodyPart(part);
}
return makeEmail(data, template, body, allowReply);
}
示例5: DispositionNotification
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
public DispositionNotification() throws AS2MessageException {
multiPart = new MimeMultipart();
textPart = new MimeBodyPart();
reportPart = new MimeBodyPart();
reportValues = new InternetHeaders();
try {
multiPart.setSubType(CONTENT_SUBTYPE);
multiPart.addBodyPart(textPart);
multiPart.addBodyPart(reportPart);
}
catch (MessagingException e) {
throw new AS2MessageException("Unable to construct a new disposition notification", e);
}
}
示例6: createMixedMultipartAttachments
import javax.mail.internet.MimeMultipart; //导入方法依赖的package包/类
private MimeMultipart createMixedMultipartAttachments(MailConfiguration configuration, Exchange exchange)
throws MessagingException, IOException {
// fill the body with text
MimeMultipart multipart = new MimeMultipart();
multipart.setSubType("mixed");
addBodyToMultipart(configuration, multipart, exchange);
String partDisposition = configuration.isUseInlineAttachments() ? Part.INLINE : Part.ATTACHMENT;
AttachmentsContentTransferEncodingResolver contentTransferEncodingResolver = configuration.getAttachmentsContentTransferEncodingResolver();
if (exchange.getIn().hasAttachments()) {
addAttachmentsToMultipart(multipart, partDisposition, contentTransferEncodingResolver, exchange);
}
return multipart;
}