Forum Moderators: open

Message Too Old, No Replies

CDO Email problem with attachments

Using conditional statement to determine attachment

         

legend

8:07 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



Hi,
First off I am new here, and I look forward to being an active part of this board.

With that being said, I am having a problem adding an attachment in one of my pages. I am including an elseif statement to meet a certain set of parameters. This will determine what file to attach.

It won't work and, for the life of me, I cannot figure it out.

--------------------------------

With iMsg

Set .Configuration = iConf

.To = "me@me.com"

.From = "you@you.com"

.Subject = "Terms and Conditions for - " &objrs("custName")

.addattachment If (L >= 2002-11-05 AND <= 2004-10-14) AND (O = REPL) THEN
"http://www.accounthotline.com/tc/amtrust/replace.txt"
ElseIf (L >= 2002-11-05 AND <= 2004-10-14) AND (O = SCAR) THEN
"http://www.accounthotline.com/tc/amtrust/repar.txt"
ElseIf (L >= 2002-11-05 AND <= 2004-10-14) AND (O = SHOM) THEN
"http://www.accounthotline.com/tc/amtrust/repar.txt"
ElseIf (L >= 2002-11-05 AND <= 2004-10-14) AND (O = REPL) AND (F = FL) THEN
"http://www.accounthotline.com/tc/amtrust/replaceFL.txt"
ElseIf (L >= 2002-11-05 AND <= 2004-10-14) AND (O = SCAR) AND (F = FL) THEN
"http://www.accounthotline.com/tc/amtrust/repairFL.txt"
ElseIf (L >= 2002-11-05 AND <= 2004-10-14) AND (O = SHOM) AND (F = FL) THEN
"http://www.accounthotline.com/tc/amtrust/repairFL.txt"
ElseIf (L >= 2004-10-15) AND (O = REPL) THEN
"http://www.accounthotline.com/tc/marathon/replace.txt"
ElseIf (L >= 2004-10-15) AND (O = SCAR) THEN
"http://www.accounthotline.com/tc/marathon/repair.txt"
ElseIf (L >= 2004-10-15) AND (O = SHOM) THEN
"http://www.accounthotline.com/tc/marathon/repair.txt"
ElseIf (L >= 2004-10-15) AND (O = REPL) AND (F = FL) THEN
"http://www.accounthotline.com/tc/marathon/replaceFL.txt"
ElseIf (L >= 2004-10-15) AND (O = SCAR) AND (F = FL) THEN
"http://www.accounthotline.com/tc/marathon/repairFL.txt"
ElseIf (L >= 2004-10-15) AND (O = SHOM) AND (F = FL) THEN
"http://www.accounthotline.com/tc/marathon/repairFL.txt"
endif

.htmlBody = " Overstock " & Body
End With
iMsg.Send

response.redirect "done.asp"

-------------------

The regular email function works fine.

.addattachment works fine if I add just one file. The problem I run into is when I try to add this conditional.

Is this even possible?

I appreciate the help.

-Larry

legend

8:12 pm on Apr 27, 2005 (gmt 0)

10+ Year Member



BTW L, O, F are variables.

If it is better to include the whole page of code let me know and I will post it.

carguy84

9:58 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't put a conditional statement where a value is expected. Move the If/Elseifs above the addattachment call, and put the URL into a variable, then just call:

.addAttachment var

Chip-

legend

1:34 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



I didn't even think of that. Let me go try it, thanks for the help.

legend

4:21 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



After 3 hours of testing and debugging, I am still having a problem.

First I tested the data:
--------------------------------

F = rtrim(objrs("state"))
L = rtrim(objrs("dop"))
O = rtrim(objrs("cinhme"))

term1 = "http://www.accounthotline.com/tc/amtrust/replace.txt"
term2 = "http://www.accounthotline.com/tc/amtrust/repair.txt"
term3 = "http://www.accounthotline.com/tc/amtrust/replacefl.txt"
term4 = "http://www.accounthotline.com/tc/marathon/replace.txt"
term5 = "http://www.accounthotline.com/tc/marathon/replaceFL.txt"
term6 = "http://www.accounthotline.com/tc/marathon/repair.txt"
term7 = "http://www.accounthotline.com/tc/marathon/repairFL.txt"

response.write l & "<br>"
response.write f & "<br>"
response.write o & "<br>"

'response.write term1
'response.write term2

If
(L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
response.write term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
response.write term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
response.write term3

Elseif (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "REPL") THEN
response.write term1

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "SHOM") THEN
response.write term2

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
response.write term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
response.write term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
response.write term3

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "REPL") THEN
response.write term5

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SCAR") THEN
response.write term7

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SHOM") THEN
response.write term7

ElseIf (L >= "2004-10-15") AND (O = "REPL") THEN
response.write term4

ElseIf (L >= "2004-10-15") AND (O = "SCAR") THEN
response.write term6

ElseIf (L >= "2004-10-15") AND (O = "SHOM") THEN
response.write term6

end if
---------------------------------------------

This works fine. I get all the values I am supposed to be getting. Now I use this code (replacing response.write with .addattachment) in the email page, and I get a page cannot be displayed error.

Code:
------------------------------------------------

Set iMsg = CreateObject("CDO.Message")

Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

With Flds

.Item(cdoSendUsingMethod) = cdoSendUsingPort

.Item(cdoSMTPServer) = "10.0.240.92"

.Update

End With

With iMsg

Set .Configuration = iConf

.To = "me@me.com"

.From = "you@you.com"

.Subject = "Terms and Conditions for - " &objrs("custName")

If
(L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
.addattachment term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
.addattachment term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
.addattachment term3

Elseif (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "REPL") THEN
.addattachment term1

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "SHOM") THEN
.addattachment term2

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
.addattachment term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
.addattachment term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
.addattachment term3

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "REPL") THEN
.addattachment term5

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SCAR") THEN
.addattachment term7

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SHOM") THEN
.addattachment term7

ElseIf (L >= "2004-10-15") AND (O = "REPL") THEN
.addattachment term4

ElseIf (L >= "2004-10-15") AND (O = "SCAR") THEN
.addattachment term6

ElseIf (L >= "2004-10-15") AND (O = "SHOM") THEN
.addattachment term6
end if

.htmlBody = " Overstock " & Body
End With

iMsg.Send

response.redirect "done.asp"

_____________________________________

Am I missing something obvious here?

carguy84

7:24 pm on Apr 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dim strURL

If (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN

strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN

strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN

strURL = term3

.............
end if

With iMsg
Set .Configuration = iConf
.To = "me@me.com"
.From = "you@you.com"
.Subject = "Terms and Conditions for - " &objrs("custName")
.addattachment strURL
.htmlBody = " Overstock " & Body
End With

iMsg.Send

response.redirect "done.asp"

legend

1:14 pm on May 2, 2005 (gmt 0)

10+ Year Member



good idea, let me give this a shot.

legend

2:13 pm on May 2, 2005 (gmt 0)

10+ Year Member



No luck.

Still get a page cannot be displayed.

______________________
C = rtrim(objrs("custName"))
D = rtrim(objrs("addy"))
E = rtrim(objrs("city"))
F = rtrim(objrs("state"))
G = rtrim(objrs("zip"))
H = rtrim(objrs("orderno"))
I = rtrim(objrs("mandes"))
J = rtrim(objrs("prodes"))
K = rtrim(objrs("modNum"))
L = rtrim(objrs("dop"))
M = rtrim(objrs("parexp"))
N = rtrim(objrs("labexp"))
O = rtrim(objrs("cinhme"))

term1 = "http://www.accounthotline.com/tc/amtrust/replace.txt"
term2 = "http://www.accounthotline.com/tc/amtrust/repair.txt"
term3 = "http://www.accounthotline.com/tc/amtrust/replacefl.txt"
term4 = "http://www.accounthotline.com/tc/marathon/replace.txt"
term5 = "http://www.accounthotline.com/tc/marathon/replaceFL.txt"
term6 = "http://www.accounthotline.com/tc/marathon/repair.txt"
term7 = "http://www.accounthotline.com/tc/marathon/repairFL.txt"

dim strURL
if
(L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
strURL = term3

Elseif (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "REPL") THEN
strURL = term1

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (O = "SHOM") THEN
strURL = term2

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "REPL") THEN
strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SCAR") THEN
strURL = term3

ElseIf (L >= "2002-11-05") AND (L <= "2004-10-14") AND (F = "FL") AND (O = "SHOM") THEN
strURL = term3

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "REPL") THEN
strURL = term5

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SCAR") THEN
strURL = term7

ElseIf (L >= "2004-10-15") AND (F = "FL") AND (O = "SHOM") THEN
strURL = term7

ElseIf (L >= "2004-10-15") AND (O = "REPL") THEN
strURL = term4

ElseIf (L >= "2004-10-15") AND (O = "SCAR") THEN
strURL = term6

ElseIf (L >= "2004-10-15") AND (O = "SHOM") THEN
strURL = term6
end if

Body = "html body..."

Set iMsg = CreateObject("CDO.Message")

Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

With Flds

.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "10.0.240.92"
.Update
End With

With iMsg
Set .Configuration = iConf
.To = "me@me.com"
.From = "you@you.com"
.Subject = "Terms and Conditions for - " &objrs("custName")
.addattachment strURL

.htmlBody = " Overstock " & Body

End With

iMsg.Send

_________________________

I tried this for the hell of it

I replaced the whole if/elseif statement with this:

dim strURL
If
(L= "2005-02-08")
strURL = term3
else
strURL = term4

end if

2005-02-08 is the exact date of the record being called. The page would not display this time either.

This is driving me up the wall.

legend

4:33 pm on May 2, 2005 (gmt 0)

10+ Year Member



i finally got it....

your method works great. I just had to put the "if" on the same line as the first conditional.

Thanks a ton.

Larry