LEGACY/CLASSIC ASP/VB Synatx to use with CDOSYS msg=msg

Classic ASP with CDOSYS - syntax question:

I was using an old smtp sendmail script and ASP/VB to email formatted data from a webpage form
and was successfully creating the ‘message’ for the send using this syntax:

message = message & " " & VBCrLF & VBCrLF
message = message & "--------- Family Registration Information ---------" & VBCrLF & VBCrLf
message = message & "Parent 1: " & parent1 & "" & VBCrLf
message = message & mother & " " & mdob & "" & VBCrLf
message = message & "Mobile #: " & mmobile & "" & VBCrLf
message = message & mprof & " " & mco & " " & mwork & " " & VBCrLf
message = message & "Email Address: " & memail & "" & VBCrLf & VBCrLf
' etc...

When I changed over to creating a sendmail object using CDOSYS,
that same syntax for creating [ObjSendMail.TextBody = message] failed, throwing a VB/asp script error

If I change the [message = message] to this (below), it works:

message = message 
& "--------- Family Registration Information ---------" & VBCrLF & VBCrLf 
& "Parent 1: " & parent1 & "" & VBCrLf & mother & " " & mdob & "" & VBCrLf & "Mobile #: " & mmobile & "" & VBCrLf & mprof & " " & mco & " " & mwork & " " & VBCrLf & "Email Address: " & memail & "" & VBCrLf & VBCrLf

I hate this because it looks sloppy and is un-readbale. making it prone to errors when editing/changing.

Is there a way to keep my VB/asp [message = message] declaration looking neat and tidy so that will it will work with CDOSYS?

Do you recall the exact syntax error, as your code doesn’t seem to show any syntax errors…

You should be able to do the following too (if I remember my vb correctly)

message = message & "--------- Family Registration Information ---------" & VBCrLF & VBCrLf _
  & "Parent 1: " & parent1 & "" & VBCrLf _
  & mother & " " & mdob & "" & VBCrLf _
  & "Mobile #: " & mmobile & "" & VBCrLf _
  & mprof & " " & mco & " " & mwork & " " & VBCrLf _
  & "Email Address: " & memail & "" & VBCrLf & VBCrLf

_ means look to the next line for more code related to this statement.

1 Like

Thank you - that’s EXCATLY what I was missing!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.