That's perfect! Thanks Philippe! Ken
On Oct 30, 2011, at 2:15 PM, Philippe Rabier wrote: > Hi Ken, > > We use the following code to do what you want: > > … > NSMutableDictionary headers = new NSMutableDictionary(); > headers.setObjectForKey(new NSArray(language), "accept-language"); > > // WORequest will answer true when method request.isUsingWebServer() is > called and so will use Host and Port > headers.setObjectForKey("4.5", "x-webobjects-adaptor-version"); > > // Host for the url > String host = ERXProperties.stringForKeyWithDefault("yourdomain", app.host()); > headers.setObjectForKey(host, "host"); > > // Port for Url > String port = ERXProperties.stringForKey("portsettings"); > if (port != null) > headers.setObjectForKey(port, WORequest.ServerPortHeaderX); > > WORequest request = new WORequest("GET", app.adaptorPath() + "/" + app.name() > + ".woa", "HTTP/1.1", headers, new NSData(), new NSDictionary()); > > WOContext ctx = new WOContext(request); > ctx.generateCompleteURLs(); > > // Init template > WOComponent page = > ERXApplication.erxApplication().pageWithName(templateClass, ctx); > … > ERMailDeliveryHTML message = new ERMailDeliveryHTML(); > message.setComponent(page); > … > message.sendMail(); > > Philippe > > > On 29 oct. 2011, at 14:12, Ken Anderson wrote: > >> Thanks Paul. Unfortunately, currentContext() will return null, since this >> will not be running inside a request/response loop. I'm probably just going >> to create a context to use… >> >> Ken >> >> On Oct 28, 2011, at 6:51 PM, Paul Hoadley wrote: >> >>> Hi Ken, >>> >>> On 26/10/2011, at 11:40 PM, Ken Anderson wrote: >>> >>>> I would like to be able send emails generated by components in the >>>> background without a user (or a context). >>>> >>>> Does anyone have a chunk of code for creating a WOContext to be populated >>>> for generating email from a WOComponent? >>> >>> This is how I do it (Wonder-based app): >>> >>> SomeEmailComponent component = >>> ERXApplication.erxApplication().pageWithName(SomeEmailComponent.class, >>> (WOContext) >>> ERXWOContext.currentContext().clone()); >>> >>> Then later: >>> >>> ERMailDeliveryHTML mail = new ERMailDeliveryHTML(); >>> mail.setComponent(component); >>> >>> >>> -- >>> Paul. >>> >>> http://logicsquad.net/ >>> >>> >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/webobjects-dev/prabier%40me.com >> >> This email sent to prab...@me.com > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com > > This email sent to kenli...@anderhome.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com