• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

ASP to choose between field 1 or field 2

Is there a way to ask a ASP script to grab an email from one field or another.

example: strform = request.form("email1") OR request.form("email2")  

or maybe use an if command, but how?

dim strfrom
if request.form("email1") = "" then use request.form("email2")
end if

depending if section 2 or section 3 is filled, i only need one email address but it can only be from if email1 box is fill or email2 box. How can I write this?
0
clubzone
Asked:
clubzone
  • 3
  • 2
1 Solution
 
imitchieCommented:
dim strfrom
if request.form("email1") <> "" then
  strform = request.form("email1")
else
  strform = request.form("email2")
end if
0
 
clubzoneAuthor Commented:
thanks what if I need to do the same but including html, like so:

dim strfrom
if Request.Form("firstname_from") & Request.Form("lastname_from") <> "" then
  strform = Request.Form("firstname_from") & "." & Request.Form("lastname_from") & "@name.ca" & " <" & strReturnEmailAddress & ">"
else
  strform = Request.Form("firstname_to") & "." & Request.Form("lastname_to") & "@name.ca" & " <" & strReturnEmailAddress & ">"
end if

0
 
VoxEchoCommented:
are you saying that that code doesn't work? asside from not having an open tag on either of the HTML strings, i see no problems. however personally i like assigning variables rather then pulling from the form objects repeatedly

<%
dim email1   : email1 = request.form("email1")
dim email2   : email2 = request.form("email2")
dim cFirstFrom : cFirstFrom = request.form("firstname_from")
dim cLastFrom : cLastFrom = request.form("lastname_from")
dim cFirstTo  : cFirstTo = request.form("firstname_to")
dim cLastTo  : cLastTo = request.form("lastname_to")
dim cEmail
dim cName

if(email1<>"") then
 cEmail = email1
elseif(email2<>"") then
 cEmail = email2
end if

if(cEmail <>"") then
  if(cFirstFrom <> "" and cLastFrom <> "") Then
   cName = "<" & strReturnEmailAddress & ">" & cFirstFrom & "." & cLastFrom & "@name.ca" & "</" & strReturnEmailAddress & ">"
  ElseIf(cFirstTo<>"" and cLAstTo<>"") Then
   cName = "<" & strReturnEmailAddress & ">" & cFirstTo & "." & cLastTo & "@name.ca" & "</" & strReturnEmailAddress & ">"
  End IF  
End IF
 %>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
clubzoneAuthor Commented:
thanks, the code works previously, but I needed to know how to put it together when having more fields with html commands.

objCDOMail.From = cEmail       would that be correct?
0
 
clubzoneAuthor Commented:
never mind the objCDOMail.From = cname

I figured it out :)
0
 
VoxEchoCommented:
yes, cEmail should work. you can also put the real name in as well [i believe it's]

objCDOEmail.From = cFirstFrom & " " & cLastFrom & "<" & cEmail & ">"
' // Bubba Gump <myaddress@domain.com>

which will result in the real name being shown in the from field of most email programs.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now