Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cdo mail blank to field

Status
Not open for further replies.

lmayer3

Programmer
Jan 20, 2005
6
US
Morning,

Is there a way to tell the script if there is no value stop processing otherwise go ahead and use the form value?

This is what I have:

If SENDEMAIL Then
Set MailObject = Server.CreateObject("CDO.Message")
MailObject.From = FROMEMAILADDRESS
if MailObject.To = "" then ??
else MailObject.To = Request("email") end if
'other code goes here

Thanks for any help.

Laura
 
why dont you check this at the form level. Make the email field a required field.

-DNG
 
I'd love to but it's for help desk app and the techs don't want to have to put an email in. We don;t have self service yet.
 
Try this:

If SENDEMAIL Then
Set MailObject = Server.CreateObject("CDO.Message")
MailObject.From = FROMEMAILADDRESS
if MailObject.To <> "" then
MailObject.To = Request("email")
end if
'other code goes here

We wont worry about if the To address is empty. the code will only process if the To address is not empty.

-DNG
 
Is there I can get rid of the error message then:

CDO.Message.1 error '8004020c'

At least one recipient is required, but none were found.

/HelpDesk/thankyou2.asp, line 88


 
then may be you could put a dummy email...

if MailObject.To <> "" then
MailObject.To = Request("email")
else

MailObject.To = "dummy@yourdomain.com"

end if

-DNG
 
I will give that a shot thanks for all your help.
 
You might just check to see if there is any value of Request("email") before you even create the mail object.
Code:
If (Len(Request("email")) = 0) Then 
  Response.Write "You Fool!  <br> An email address is <b>required</b>!"
  Response.End  'halt execution of script
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top