JuergenO
Posts: 7
|
| Posted: 03/10/2007, 3:37 AM |
|
I've spent considerable hours playing with the TaskManager example to send emails after a record is inserted. But what I'm trying is slightly different and this example doesn't work.
The example assumes the user is already registered and when a new task is assigned it can lookup the email via the user_id. What I'm trying to do is have a user register, and then send an email to the new user's email address. But I can't lookup the user_id or email because it doesn't exist yet.
Here's what I've tried.
-------
Dim Mail
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.From = "mymail@nowhere.com"
Mail.FromName = "Administrator"
Mail.AddAddress CCDLookUp("email", "users", "user_id=" &_
DBinternetDB.ToSQL("max(user_id)", "users", ccsInteger), DBinternetDB)
Mail.Host = "mai.nowhere.com"
Mail.IsHTML = True
Mail.Subject = "Request"
Mail.Body = "You have requested ..."
Mail.Send
-------
The Mail.AddAddress line is the one causing me the headaches.
If anyone can check out my code and give me a pointer as to what I'm doing wrong, I would be most grateful.
Thanks,
Juergen
|
 |
 |
wkempees
|
| Posted: 03/10/2007, 4:27 AM |
|
Jurgen
Do exactly what you describe as being your intention:
Have the new user register, the form will be doing an Insert.
AfterInsert pick up the newly made ID (scan the forum for your flavour of
"Last inserted"
Alter your CCDLookUP to use that ID, you are already doing the Max(User_ID)
but maybe you are to early in the process.
You need to do this in AfterInsert, debug your max(User_ID) until the value
is right and all else will work.
Sounds simple, well it really is.
Walter
"JuergenO" <JuergenO@forum.codecharge> schreef in bericht
news:245f29872d4e50@news.codecharge.com...
> I've spent considerable hours playing with the TaskManager example to send
> emails after a record is inserted. But what I'm trying is slightly
> different
> and this example doesn't work.
>
> The example assumes the user is already registered and when a new task is
> assigned it can lookup the email via the user_id. What I'm trying to do is
> have
> a user register, and then send an email to the new user's email address.
> But I
> can't lookup the user_id or email because it doesn't exist yet.
>
> Here's what I've tried.
>
> -------
> Dim Mail
> Set Mail = Server.CreateObject("Persits.MailSender")
> Mail.From = "mymail@nowhere.com"
> Mail.FromName = "Administrator"
> Mail.AddAddress CCDLookUp("email", "users", "user_id=" &_
> DBinternetDB.ToSQL("max(user_id)", "users", ccsInteger), DBinternetDB)
> Mail.Host = "mai.nowhere.com"
> Mail.IsHTML = True
> Mail.Subject = "Request"
> Mail.Body = "You have requested ..."
> Mail.Send
>
> -------
>
> The Mail.AddAddress line is the one causing me the headaches.
>
> If anyone can check out my code and give me a pointer as to what I'm doing
> wrong, I would be most grateful.
>
> Thanks,
> Juergen
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
JuergenO
Posts: 7
|
| Posted: 03/20/2007, 2:03 PM |
|
Appreciate the response, Walter. I tried what you suggested, but simply couldn't get the record select statement at the right spot.
After many hours of banging my head in frustration, I switched tack: instead of sending the email with an After Insert, I went to the confirmation page and added a Send Mail to a Before Show event. Not as correct and elegant a solution, but at least it works.
Regards
Juergen
|
 |
 |
wkempees
|
| Posted: 03/20/2007, 5:43 PM |
|
Very elegant I would say.
And who says something that is working is not correct.
Good for you! well done.
Walter
"JuergenO" <JuergenO@forum.codecharge> schreef in bericht
news:245f29872d4e50@news.codecharge.com...
> I've spent considerable hours playing with the TaskManager example to send
> emails after a record is inserted. But what I'm trying is slightly
> different
> and this example doesn't work.
>
> The example assumes the user is already registered and when a new task is
> assigned it can lookup the email via the user_id. What I'm trying to do is
> have
> a user register, and then send an email to the new user's email address.
> But I
> can't lookup the user_id or email because it doesn't exist yet.
>
> Here's what I've tried.
>
> -------
> Dim Mail
> Set Mail = Server.CreateObject("Persits.MailSender")
> Mail.From = "mymail@nowhere.com"
> Mail.FromName = "Administrator"
> Mail.AddAddress CCDLookUp("email", "users", "user_id=" &_
> DBinternetDB.ToSQL("max(user_id)", "users", ccsInteger), DBinternetDB)
> Mail.Host = "mai.nowhere.com"
> Mail.IsHTML = True
> Mail.Subject = "Request"
> Mail.Body = "You have requested ..."
> Mail.Send
>
> -------
>
> The Mail.AddAddress line is the one causing me the headaches.
>
> If anyone can check out my code and give me a pointer as to what I'm doing
> wrong, I would be most grateful.
>
> Thanks,
> Juergen
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|