public static Map<String,Object> sendMailFromUrl(DispatchContext ctx,Map<String,? extends Object> rcontext){
  Map<String,Object> sendMailContext=UtilMisc.makeMapWritable(rcontext);
  String bodyUrl=(String)sendMailContext.remove("bodyUrl");
  Map<String,Object> bodyUrlParameters=UtilGenerics.checkMap(sendMailContext.remove("bodyUrlParameters"));
  Locale locale=(Locale)rcontext.get("locale");
  LocalDispatcher dispatcher=ctx.getDispatcher();
  URL url=null;
  try {
    url=new URL(bodyUrl);
  }
 catch (  MalformedURLException e) {
    Debug.logWarning(e,module);
    return ServiceUtil.returnError(UtilProperties.getMessage(resource,"CommonEmailSendMalformedUrl",UtilMisc.toMap("bodyUrl",bodyUrl,"errorString",e.toString()),locale));
  }
  HttpClient httpClient=new HttpClient(url,bodyUrlParameters);
  String body=null;
  try {
    body=httpClient.post();
  }
 catch (  HttpClientException e) {
    Debug.logWarning(e,module);
    return ServiceUtil.returnError(UtilProperties.getMessage(resource,"CommonEmailSendGettingError",UtilMisc.toMap("errorString",e.toString()),locale));
  }
  sendMailContext.put("body",body);
  Map<String,Object> sendMailResult;
  try {
    sendMailResult=dispatcher.runSync("sendMail",sendMailContext);
  }
 catch (  GenericServiceException e) {
    Debug.logError(e,module);
    return ServiceUtil.returnError(e.getMessage());
  }
  return sendMailResult;
}

public static Map < String , Object > sendMailFromUrl ( DispatchContext ctx , Map < String , ? extends Object > rcontext ) { Map < String , Object > sendMailContext = UtilMisc . makeMapWritable ( rcontext ) ; String bodyUrl = ( String ) sendMailContext . remove ( "bodyUrl" ) ; Map < String , Object > bodyUrlParameters = UtilGenerics . checkMap ( sendMailContext . remove ( "bodyUrlParameters" ) ) ; Locale locale = ( Locale ) rcontext . get ( "locale" ) ; LocalDispatcher dispatcher = ctx . getDispatcher ( ) ; URL url = null ; try { url = new URL ( bodyUrl ) ; } catch ( MalformedURLException e ) { Debug . logWarning ( e , module ) ; return ServiceUtil . returnError ( UtilProperties . getMessage ( resource , "CommonEmailSendMalformedUrl" , UtilMisc . toMap ( "bodyUrl" , bodyUrl , "errorString" , e . toString ( ) ) , locale ) ) ; } HttpClient httpClient = new HttpClient ( url , bodyUrlParameters ) ; String body = null ; try { body = httpClient . post ( ) ; } catch ( HttpClientException e ) { Debug . logWarning ( e , module ) ; return ServiceUtil . returnError ( UtilProperties . getMessage ( resource , "CommonEmailSendGettingError" , UtilMisc . toMap ( "errorString" , e . toString ( ) ) , locale ) ) ; } sendMailContext . put ( "body" , body ) ; Map < String , Object > sendMailResult ; try { sendMailResult = dispatcher . runSync ( "sendMail" , sendMailContext ) ; } catch ( GenericServiceException e ) { Debug . logError ( e , module ) ; return ServiceUtil . returnError ( e . getMessage ( ) ) ; } return sendMailResult ; }
javamail service that gets body content from a url
