Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

code doesn't work

Posted on 2007-12-04
8
Medium Priority
?
208 Views
Last Modified: 2010-04-21
Hello Everyone the code below does not work... can you help me figure out why?

if contactEmail = "" then
      contactEmail = "fake@fake.com"
end if
response.write contactEmail
response.End()
________________________________________________________________

Like for example if contactEmail  is blank, why does it not get replaced with the email I have as the default?!?!

________________________________________________________________

if contactEmail = "" then
      contactEmail = "fake@fake.com"
end if
response.write contactEmail
response.End()

'I get  blank, no email, even though logically it should give me the default email, how do I set a default email in this case?
________________________________________________________________


opicSubject = "Section IA."
opicBody = "body"

sendEmail emailBody, subject, recipient  'call function, send email if the data was submitted correctly


function sendEmail(body, subject, recepient)
            set objMail=Server.CreateObject("Jmail.SMTPMail")
                  objMail.ServerAddress = "00.00.00.00"
                  objMail.AddRecipient(recepient)      
                  objMail.Sender = "fake@fake.com"
                  objMail.Subject=subject                  
                  objMail.Body=body
                  objMail.Execute  
            end if             
            set objMail=nothing
end function




SO I GET THIS ERROR:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'objMail.AddRecipient'



because it cannot find an recepient
0
Comment
Question by:Gemini532
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20407081
Gemini532,

It looks like the problem is you aren't passing the variable to the function.  Try ...

sendEmail emailBody, subject, contactEmail  'call function, send email if the data was submitted correctly

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20407119
Gemini532,

Regarding the first part of the question the code looks good.  Most likely contactEmail is something else and not going in the If.  Try using ...

if contactEmail = "" then
      contactEmail = "fake@fake.com"
end if
response.write "The email is [" & contactEmail &"] and the type is " & Typename(contactEmail)
response.End()


Let me know if you have a question.

b0lsc0tt
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20408087
If the email is "blank", and it's not an empty string, then it's likely Empty (null).

If IsEmpty(contactEmail) or contactEmail = "" Then
      contactEmail = "fake@fake.com"
End If

If you for example read a value from Request.QueryString, and no value was supplied in the url, the value that you get is not an empty string, it's the Empty value.

When you are calling the sendEmail function (which should actually be a Sub as it doesn't return any value), you don't use the variables that you have assigned on the previous lines. Have you assigned any values to the variables that you use?

Do you have Option Explicit in your code? If you don't, it will silently create new variables if you use variables that you haven't declared, or if you don't spell the variable names the same. I noticed that you used two different spellings for recipient/recepient (of which recipient is the correct spelling).
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Gemini532
ID: 20441927
I got this from response.end

The email is [] and the type is Null
0
 

Author Comment

by:Gemini532
ID: 20442123
Does this help, if no one enters something if the email field it shows up as <NULL> in the database
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 2000 total points
ID: 20442625
Ok, then the value is Null, which is a special value that means that the value comes from a database field that was null, and it's not the same thing as Empty.

If IsNull(contactEmail) Then
      contactEmail = "fake@fake.com"
End If

Perhaps you also want to check if the value is an empty string (from an empty non-null database value):

If IsNull(contactEmail) or contactEmail = "" Then
      contactEmail = "fake@fake.com"
End If
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20443326
Thanks for trying that and posting the results.  That is what we needed. :)

GreenGhost's last post should have the solution you need.  I'd recommend the second code so you still would test for an empty value.  You might also consider changing the database to not allow Null values in that field.  That might be more work right now or may not even be an option but could save you in the long run.  If you do allow Null values in a database then you need to remember that when writing the script that will check those values.

Let us know if you have a question about what has been said.  GreenGhost's last post should be exactly what you need though.  Thanks again for the results.

bol
0
 

Author Closing Comment

by:Gemini532
ID: 31412708
THANK YOU!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question