本文整理汇总了Java中org.apache.commons.mail.util.MimeMessageParser类的典型用法代码示例。如果您正苦于以下问题:Java MimeMessageParser类的具体用法?Java MimeMessageParser怎么用?Java MimeMessageParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MimeMessageParser类属于org.apache.commons.mail.util包,在下文中一共展示了MimeMessageParser类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMessages
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
private List<MimeMessageParser> getMessages() {
List<MimeMessageParser> emails = new ArrayList<>();
for (MimeMessage msg : mailTestService.getEmails()) {
MimeMessageParser parser = new MimeMessageParser(msg);
try {
parser.parse();
} catch (Exception ex) {
log.warn("Parsing mail body failed.");
}
emails.add(parser);
}
return emails;
}
开发者ID:mattpwest,项目名称:entelect-spring-webapp-template,代码行数:14,代码来源:EmailTestController.java
示例2: createTask
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
private void createTask(MimeMessageParser message, Project project, User actor) throws Exception {
String taskTitle = message.getSubject()
.replaceFirst("(?i)todo: ", "")
.replaceFirst("(?i)todo:", "")
.replaceFirst("(?i)todo", "")
;
Task task = new Task();
task.setProject(project);
task.setTitle(taskTitle);
task.setDescription(message.getPlainContent());
// find assingee
User assignee = null;
List<Address> addresses = new ArrayList<Address>();
addresses.addAll(message.getTo());
addresses.addAll(message.getCc());
addresses.addAll(message.getBcc());
for (Address rawAddress : addresses) {
InternetAddress address = (InternetAddress) rawAddress;
if (!AppHelper.isAppEmail(address.getAddress())) {
if (UserService.getInstance().isUserProvisioned(address.getAddress())) {
User user = UserService.getInstance().getUser(address.getAddress());
if (project.hasUser(user)) {
task.setAssigneeEntity(user);
break;
}
}
}
}
TaskService.getInstance().save(task,actor);
}
开发者ID:andryfailli,项目名称:teampot,代码行数:35,代码来源:MailHandlerTaskMailSubscriber.java
示例3: bodyPecWithAttachment
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
public static void bodyPecWithAttachment(InputStream imailstream, PECMail mail,File attachmentPecDir) throws Exception {
File attachmentDir = new File( attachmentPecDir.getAbsolutePath() + relativePath );
attachmentDir.mkdirs();
final Properties props = System.getProperties();
final Session session = Session.getDefaultInstance(props, null);
final MimeMessage msg = new MimeMessage(session, imailstream);
MimeMessageParser parser = new MimeMessageParser(msg);
parser.parse();
mail.setHasAttachments(parser.hasAttachments());
if (parser.hasAttachments()) {
for (DataSource data : parser.getAttachmentList()) {
String nameRelativeFile = relativePath +data.getName();
File attachment = new File( attachmentPecDir.getAbsolutePath() + nameRelativeFile );
FileOutputStream output = new FileOutputStream(attachment);
IOUtils.copy(data.getInputStream(), output);
IOUtils.closeQuietly(data.getInputStream());
IOUtils.closeQuietly(output);
FileInfo fileInfo = new FileInfo(attachment,nameRelativeFile);
mail.getAttachments().add(fileInfo);
}
}
if (parser.getHtmlContent() != null) {
mail.setBodyType("html");
mail.setBody(parser.getHtmlContent());
} else {
mail.setBodyType("text");
mail.setBody(parser.getPlainContent());
}
}
开发者ID:tornabene,项目名称:jopenpec,代码行数:36,代码来源:PECVerifier.java
示例4: processMessage
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
@Override
public void processMessage(MimeMessageParser message, Project project, User actor) throws Exception {
if (message.getSubject().toLowerCase().indexOf("todo")>=0) {
this.createTask(message, project, actor);
}
}
开发者ID:andryfailli,项目名称:teampot,代码行数:7,代码来源:MailHandlerTaskMailSubscriber.java
示例5: processMessage
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
public void processMessage(MimeMessage mimeMessage) throws Exception {
MimeMessageParser message = new MimeMessageParser(mimeMessage);
message.parse();
Project project = null;
// find project id
List<Address> addresses = new ArrayList<Address>();
addresses.addAll(message.getTo());
addresses.addAll(message.getCc());
addresses.addAll(message.getBcc());
for (Address rawAddress : addresses) {
InternetAddress address = (InternetAddress) rawAddress;
String mayBeProjectId = address.getAddress().split("@")[0];
project = ProjectService.getInstance().getByName(mayBeProjectId);
if (project != null) {
break;
}
}
if (project == null) {
logger.info("No target project found. Ignoring email.");
return;
}
String[] inReplyToheader = mimeMessage.getHeader("In-Reply-To");
if (inReplyToheader != null && inReplyToheader.length>0) {
logger.info("It's a reply because 'In-Reply-To' header found. Ignoring email.");
return;
}
String from = InternetAddress.parse(message.getFrom())[0].getAddress();
if (!UserService.getInstance().isUserProvisioned(from)) {
logger.info("User "+from+" does not exists. Ignoring email.");
return;
}
User actor = UserService.getInstance().getUser(from);
if (!project.hasUser(actor)) {
logger.info("User "+actor.getEmail()+" is not in "+project.getMachineName()+"'s team. Ignoring email.");
return;
}
// finally
logger.info("Wow, that's an important email. Let's process it...");
for (MailHandlerSubscriber subscriber : subscribers) {
subscriber.processMessage(message,project,actor);
}
}
开发者ID:andryfailli,项目名称:teampot,代码行数:53,代码来源:MailHandlerService.java
示例6: extractPecMail
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
private PECMail extractPecMail(MimeMessage message,File attachmentDirParent ) throws Exception {
final PECMail pecMail = new PECMail();
String f = attachmentDirParent.getAbsolutePath();
File attachmentPecDir = new File(f);
attachmentPecDir.mkdirs();
MimeMessageParser parser = new MimeMessageParser(message);
parser.parse();
if (parser.hasAttachments()) {
for (DataSource data : parser.getAttachmentList()) {
if(PecConstant.POSTACERT.equals( data.getName() ) ){
File postacert = new File( attachmentPecDir.getAbsolutePath() +"/" + data.getName() );
FileOutputStream output = new FileOutputStream(postacert);
IOUtils.copy(data.getInputStream(), output);
IOUtils.closeQuietly( output );
FileInputStream imailstream = new FileInputStream( postacert );
bodyPecWithAttachment(imailstream, pecMail, attachmentPecDir);
}
}
}
return pecMail;
}
开发者ID:tornabene,项目名称:jopenpec,代码行数:36,代码来源:PECVerifier.java
示例7: processMessage
import org.apache.commons.mail.util.MimeMessageParser; //导入依赖的package包/类
public abstract void processMessage(MimeMessageParser message, Project project, User actor) throws Exception;
开发者ID:andryfailli,项目名称:teampot,代码行数:2,代码来源:MailHandlerSubscriber.java
注:本文中的org.apache.commons.mail.util.MimeMessageParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论