Rosario
Posts: 54
|
| Posted: 06/15/2005, 8:24 AM |
|
PLEEEEZZZZZ
How do i send email based on what a user selects in a form? For instance I have a dropdown that contains 12345 as selectable posibilities. If the user selects 5, i want to be able to have the form send email. But how?
|
 |
 |
Nicole
Posts: 586
|
| Posted: 06/16/2005, 12:49 AM |
|
Rosario,
You can add "if" statement around send email code where check a value returned from a listbox control, e.g.
If form_name.lisbox_name.Value = 5 then
' send email code
End if
_________________
Regards,
Nicole |
 |
 |
Rosario
Posts: 54
|
| Posted: 06/16/2005, 8:31 AM |
|
Thanks, Looks like i might get this working after all, but i am not sure my placement is right, I am getting a 500 server error. What do you think? Here is my code.
Function TASK_AfterUpdate() 'TASK_AfterUpdate @2-E292D521
If form_name.INPUT_BY.Value = Sandra then
'Send Email @19-E67FB923
With CreateObject("CDONTS.NewMail")
.From = TASK.EMAIL.Text
.To = TASK.EMAIL.Text
.Subject = TASK.DESCRIPTION1.Text
.Body = TASK.DLC_TYPE.Text
.BodyFormat = 1
.MailFormat = 0
.Send
End With
'End Send Email
End if
End Function 'Close TASK_AfterUpdate @2-54C34B28
|
 |
 |
Rosario
Posts: 54
|
| Posted: 06/16/2005, 8:31 AM |
|
Thanks, Looks like i might get this working after all, but i am not sure my placement is right, I am getting a 500 server error. What do you think? Here is my code.
Function TASK_AfterUpdate() 'TASK_AfterUpdate @2-E292D521
If TASK.INPUT_BY.Value = Sandra then
'Send Email @19-E67FB923
With CreateObject("CDONTS.NewMail")
.From = TASK.EMAIL.Text
.To = TASK.EMAIL.Text
.Subject = TASK.DESCRIPTION1.Text
.Body = TASK.DLC_TYPE.Text
.BodyFormat = 1
.MailFormat = 0
.Send
End With
'End Send Email
End if
End Function 'Close TASK_AfterUpdate @2-54C34B28
|
 |
 |
smalloy
Posts: 107
|
| Posted: 06/16/2005, 8:41 AM |
|
Rosario,
Could it be that there are quotes missing around Sandra?
i.e.:
If TASK.INPUT_BY.Value = "Sandra" Then
_________________
Anything can be done, just give me time and money. |
 |
 |
Rosario
Posts: 54
|
| Posted: 06/16/2005, 8:47 AM |
|
Indeed, you are correct sir, that did it...thanks!
Anyway Where do you think code like this should be placed? I have it in After update, but I wonder if it would not be better sutied somewhere else.
|
 |
 |
smalloy
Posts: 107
|
| Posted: 06/16/2005, 11:16 AM |
|
Well, after update will only trigger if the record was edited, not when a new one is created (After_Insert). If you want the email sent for both, edited records and new ones then I recommend making your own function! Its very easy, just go to the bottom of the page, something_EVENTS.asp and add:
Function send_user_email()
'Send Email to the user
With CreateObject("CDONTS.NewMail")
.From = TASK.EMAIL.Text
.To = TASK.EMAIL.Text
.Subject = TASK.DESCRIPTION1.Text
.Body = TASK.DLC_TYPE.Text
.BodyFormat = 1
.MailFormat = 0
.Send
End With
'End Send Email
End if
End Function
Then just call the fuction in both the After Update and After Insert events, like this:
Function TASK_AfterUpdate() 'TASK_AfterUpdate @2-E292D521
If TASK.INPUT_BY.Value = "Sandra" Then
'Call the send email function
Call send_user_email
End if
End Function 'Close TASK_AfterUpdate @2-54C34B28
Make sense? You could easily just copy the code into both events but that's bad for a lot of reasons, the biggest is that if you need to change the code, you'll need to go to everyplace that it exists, here, one change and your done!
_________________
Anything can be done, just give me time and money. |
 |
 |
smalloy
Posts: 107
|
| Posted: 06/16/2005, 11:19 AM |
|
Well, after update will only trigger if the record was edited, not when a new one is created (After_Insert). If you want the email sent for both, edited records and new ones then I recommend making your own function! Its very easy, just go to the bottom of the page, something_EVENTS.asp and add:
Function send_user_email()
'Send Email to the user
With CreateObject("CDONTS.NewMail")
.From = TASK.EMAIL.Text
.To = TASK.EMAIL.Text
.Subject = TASK.DESCRIPTION1.Text
.Body = TASK.DLC_TYPE.Text
.BodyFormat = 1
.MailFormat = 0
.Send
End With
'End Send Email
End if
End Function
Then just call the fuction in both the After Update and After Insert events, like this:
Function TASK_AfterUpdate() 'TASK_AfterUpdate @2-E292D521
If TASK.INPUT_BY.Value = "Sandra" Then
'Call the send email function
Call send_user_email
End if
End Function 'Close TASK_AfterUpdate @2-54C34B28
Make sense? You could easily just copy the code into both events but that's bad for a lot of reasons, the biggest is that if you need to change the code, you'll need to go to everyplace that it exists, here, one change and your done!
_________________
Anything can be done, just give me time and money. |
 |
 |
|