CDONTS TO and From mail to be stored in DB

54 views Asked by At

I have an old application which sends mail using CDONTS in classic ASP.

Now, I wanted to store the to and from addresses of every mail sent in a database.

Dim a="' & 'FirstName LastName'<emailaddress>'"
trixMail.From= a
Dim b =  "anotheremailaddress"
trixMail.To = b 

a =TrixMail.From

b= TrixMail.To
Dim MM_query  
Dim MM_editCmd
MM_query =  "Insert into Logmail(FromEmail,ToEmail) values('"+a+"', '"+b+"')"

Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_dbConn_STRING
MM_editCmd.CommandText = MM_query
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

So, this is what I'm doing. However , i get an error saying

Expected end of statement at the line i declare variable 'a'.

So, can u let me know where I'm going wrong?

1

There are 1 answers

0
ThatGuyInIT On BEST ANSWER

This line is the problem:

Dim a="' & 'FirstName LastName'<emailaddress>'"

Change to

Dim a: = """FirstName LastName"" <emailaddress>"

or

Dim a
a = """FirstName LastName"" <emailaddress>"

I have removed the name and e-mail address you posted, replace as needed.