Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Using Classic ASP Sendmail and getting 2 emails sent!

Avatar of Terri Alekzander
Terri AlekzanderFlag for United States of America asked on
ASPEmail Servers
10 Comments1 Solution1225 ViewsLast Modified:
It has been some time since I coded anything in ASP and I am struggling.  I finally got the mail settings I needed from teh administrator and have mail going through.  I've been having problems with the body of the email which is mainly content pulled from a form on the website.  I admit that in desperation I started cutting and pasting code from all different resources and now I am receiving two emails from the submission of the form.  One email has the message of the email completed properly.  The second email is missing all the form content.  I am apparently sending the email twice, but I am going blind trying to find what I've done wrong.  I've attached the code below.
Sub sendEmail(mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword)
Set MyMail = CreateObject("cdo.message")
MyMail.From = mailFrom
MyMail.To = mailTo
MyMail.Subject = mailSubject
MyMail.HTMLBody = mailMessage
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailUsername
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailPassword
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Set MyMail = nothing
End Sub
Dim mailFrom, mailTo, mailSubject, strHtmlBody, mailServer, mailUsername, mailPassword
Dim requiredfname, requiredlname, company, street, street2, city, addystate, zip, country, requiredemail
Dim requiredpareacode, requiredphone, fareacode, fax, project
Dim ObjSendMail
Set objSendMail = CreateObject("CDO.Message")
requiredfname = Request.Form("requiredfname")
requiredlname = Request.Form("requiredlname")
company = Request.Form("company")
street = Request.Form("street")
street2 = Request.Form("street2")
city = Request.Form("city")
addystate = Request.Form("addystate")
zip = Request.Form("zip")
country = Request.Form("country")
requiredemail = Request.Form("requiredemail")
requiredpareacode = Request.Form("requiredpareacode")
requiredphone = Request.Form("requiredphone")
fareacode = Request.Form("fareacode")
fax = Request.Form("fax")
project = Request.Form("project")
mailFrom = "mailfrom address goes here"
mailTo = "mail to address goes here"
mailSubject = "Quote from CHS website"
		strHtmlBody = "<HTML><HEAD></head><BODY>" & vbcrlf
		strHtmlBody = strHtmlBody+ "<p>" & requiredfname & " " & requiredlname
		strHtmlBody = strHtmlBody+ "<br>" & company
		strHtmlBody = strHtmlBody+ "<br>" & street
		strHtmlBody = strHtmlBody+ "<br>" & street2
		strHtmlBody = strHtmlBody+ "<br>" & city & ", " & addystate & " " & zip
		strHtmlBody = strHtmlBody+ "<br>" & country
		strHtmlBody = strHtmlBody+ "<br><br>"
		strHtmlBody = strHtmlBody+ "<br>" & requiredemail
		strHtmlBody = strHtmlBody+ "<br>" & requiredpareacode & "-" & requiredphone
		strHtmlBody = strHtmlBody+ "<br>" & fareacode & "-" & fax
		strHtmlBody = strHtmlBody+ "<br><br>"
		strHtmlBody = strHtmlBody+ "<br>" & project
		strHtmlBody = strHtmlBody+ "</p></body></html>"
objSendMail.HTMLBody = strHtmlBody
mailServer = "i have server info for here"
mailUsername = "i have username for here"
mailPassword = "i have password for here"
Call sendEmail(mailFrom, mailTo, mailSubject, strHTMLBody, mailServer, mailUsername, mailPassword)
Avatar of psufan
psufanFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answers