전자 메일을 만드는 데 GUI가 필요한 이유가 무엇입니까? 전자 메일 콘텐츠를 HTML 태그를 포함하는 대신 최대한 간단하게 유지하는 것이 가장 좋습니다. 사용자가 일반/텍스트로 전자 메일을 열기로 결정한 경우 그 태그는 추악한 태그 일뿐입니다. 같은 속도 나 프리 마커로
사용하여 템플릿 엔진은 이메일 템플릿을 만드는 법 갈 수있는 방법입니다. 임시 전자 메일 인 경우에도 전자 메일 서식 파일을 사용하여 머리글과 바닥 글을 동일하게 유지하고 임의의 메시지로 본문 내용을 스왑 할 수 있습니다.
예외 email.vm 파일
** Please do not reply to this message **
The project administrator has been notified regarding this error.
Remote Host : $remoteHost
Server : $serverName
Request URI : $requestURI
User ID : $currentUser
Exception :
$stackTrace
문자열로 구성된 전자 우편을 얻으려면, 내가 할 - 내 프로젝트에서
,이 같은 속도를 사용하여 이메일 템플릿을 다음 : - :
-
private String getMessage(HttpServletRequest request, Throwable t) {
Map<String, String> values = new HashMap<String, String>();
values.put("remoteHost", request.getRemoteHost());
values.put("serverName", request.getServerName());
values.put("requestURI", request.getRequestURI());
values.put("currentUser", ((currentUser != null) ? currentUser.getLanId() : "(User is undefined)"));
StringWriter sw = new StringWriter(500);
t.printStackTrace(new PrintWriter(sw));
values.put("stackTrace", sw.toString());
return VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "exception-email.vm", values);
}
부여, 나는 velocityEngine
에 와이어 스프링을 사용하고 있습니다
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<props>
<prop key="resource.loader">class</prop>
<prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
</props>
</property>
</bean>