Array and Email issue/question

  • Thread starter Thread starter sjsean
  • Start date Start date
S

sjsean

The page I am using works fine when just using hand entered values in
the page itself ie objMM.To = "(e-mail address removed)"

The problem I am having is I can't seem to "translate" the array I
have of values into a string that would be useable for the .Body
portion. Does anyone have suggestions or recommendations of an
article I could read?

dim cartArray
dim i

cartArray=session("cartArray")

i = cartArray(0,0)

objMM.Body = ???


Again any help is appreciated.

S
 
The page I am using works fine when just using hand entered values in
the page itself ie objMM.To = "(e-mail address removed)"

The problem I am having is I can't seem to "translate" the array I
have of values into a string that would be useable for the .Body
portion. Does anyone have suggestions or recommendations of an
article I could read?

dim cartArray
dim i

cartArray=session("cartArray")

i = cartArray(0,0)

objMM.Body = ???

Again any help is appreciated.

S

you can use For-Each loop, or LBound/UBound for iterating the contents
of an array

Dim i As Integer
Dim s As String

For i = LBound(cartArray) To UBound(cartArray)
s = s & cartArray(i) & vbCrLf
Next

objMM.Body = s

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

Dim cartItem as String
Dim s As String

For Each cartItem in cartArray
s = s & cartItem & vbCrLf
Next

objMM.Body = s
 
you can use For-Each loop, or LBound/UBound for iterating the contents
of an array

Dim i As Integer
Dim s As String

For i = LBound(cartArray) To UBound(cartArray)
s = s & cartArray(i) & vbCrLf
Next

objMM.Body = s

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

Dim cartItem as String
Dim s As String

For Each cartItem in cartArray
s = s & cartItem & vbCrLf
Next

objMM.Body = s- Hide quoted text -

- Show quoted text -

I hopefully tried what was suggested and got the following error when
trying to process:

BC30471: Expression is not an array or a method, and cannot have an
argument list.

Line 15: for h = 0 to 13
Line 16:
Line 17: msg = msg & cartArray(h,i) & vbCrLf <---- problem line
Line 18:
Line 19: Next

code from page is:

<% @Import Namespace="System.Web.Mail" %>
<% @LANGUAGE="VBScript" Debug="true" %>
<%

dim i as integer
dim h as integer
dim cartMaxUsed as integer
dim cartArray as string
dim msg as string

cartMaxUsed = session("cartMaxUsed")
cartArray = session ("cartArray")

for i = 0 to cartMaxUsed
for h = 0 to 13

msg = msg & cartArray(h,i) & vbCrLf

Next

Next


'Create an instance of the MailMessage class

Dim objMM As MailMessage = New MailMessage()

and so forth with mail message settings.

cartMaxUsed is total number of items in cart
there are 14 field items I have collected for each cart item.

Thanks for the advice.

sean
 
BC30471: Expression is not an array or a method, and cannot have an
argument list.

It's because you declared a string and not an array:

dim cartArray as string

An array has to be declared as:

dim cartArray() as string

Declare multi-dimensional array by separating the dimensions with
commas:

dim cartArray(,) as string

Then you can use the ReDim statement to declare the size of the
array:

ReDim cartArray(13, cartMaxUsed)
 
Back
Top