Re: WOmailer
Re: WOmailer
- Subject: Re: WOmailer
- From: David LeBer <email@hidden>
- Date: Wed, 1 Dec 2004 15:30:55 -0500
On Dec 1, 2004, at 11:01 AM, David Griffith wrote:
Hi all,
A quick question on JavaMail. When using ERJavaMail to send a mail,
it also
attempts to display that page in the browser. In one particular
instance, I
call a method that creates and sends the mail and then returns a
different
page entirely which works fine. However if I want to send the mail and
return the current page in it's current state, I would normally return
null
to just refresh the existing page. However it appears that at the
point
where I return null it has already 'gone' to the Email page. Is there
some
way to tell it to send the mail 'in the background' so to speak so
that it
does not affect the page the user is currently viewing?
This has worked for me in the past. I had code in my component that
looked something like this:
public WOComponent clientOrderNotification(Order order)
{
int otn = order.otn().intValue();
NSMutableDictionary emailDict = new NSMutableDictionary();
emailDict.setObjectForKey("email@hidden","emailFrom" );
emailDict.setObjectForKey((String)order.valueForKeyPath(
"creator.emailAddress"), "emailAddress"
);
emailDict.setObjectForKey("Blah order "+otn+" approved!",
"emailSubject" );
e_OrderApprovedEmail aPage =
(e_OrderApprovedEmail)pageWithName("e_OrderApprovedEmail");
aPage.setOrder(order);
app().sendMail(aPage, emailDict);
return null;
}
And something like this in my Application.java
public void sendMail(WOComponent page, NSDictionary dict)
{
System.out.println("Sending mail");
ERMailDeliveryWOComponentPlainText mail = new
ERMailDeliveryWOComponentPlainText();
mail.setComponent (page);
try {
mail.newMail ();
mail.setFromAddress((String)dict.valueForKey("emailFrom"));
mail.setReplyToAddress((String)dict.valueForKey("emailFrom"));
mail.setSubject((String)dict.valueForKey("emailSubject"));
NSMutableArray emailAddresses = new NSMutableArray();
emailAddresses.addObject((String)dict.valueForKey("emailAddress"));
mail.setToAddresses(emailAddresses);
// Send the mail
mail.sendMail ();
} catch (Exception e) {
System.out.println("We have an exception " + e);
}
}
ERJavaMail is multithreaded, and should spawn a new thread to send your
mail.
;david
--
David LeBer
Codebase Software Systems
site: http://www.codebase.ca
blog: http://david.codebase.ca
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Re: WOmailer (From: David Griffith <email@hidden>) |