Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:51:20+00:00 2026-06-11T10:51:20+00:00

Ok, so my problem is this. I have a simple vbscript that sends an

  • 0

Ok, so my problem is this. I have a simple vbscript that sends an email when the form is submit. When it is in the code as follows, if sends the email (I receive the email in my inbox) undesirable twice: Once when the page loads, and once on submit:

<% 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
MyMail.Configuration.Fields.Update
MyMail.Send
Set MyMail = nothing
End Sub

Dim mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword

mailFrom = "example"
mailTo = "example"
mailSubject = "Email test"
mailMessage = "<html><body>example</body><html>"
mailServer = "example"
mailUsername = "example"
mailPassword = "example"

Call sendEmail(mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword)%>

So I figured I had to do something like this so it only sends once. Add a hidden field to the form under the submit button, and edit the code to this. The only problem is, when I do this, the form appears to submit properly and no errors occur, but I never get the email in my inbox! Any help would be GREATLY appreciated. I’m not the best at this stuff, and I’m still learning!:

<% if request.form("isSubmitted") = "yes" then
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
MyMail.Configuration.Fields.Update
MyMail.Send
Set MyMail = nothing
End Sub

Dim mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword

mailFrom = "example"
mailTo = "example"
mailSubject = "Email test"
mailMessage = "<html><body>example</body><html>"
mailServer = "example"
mailUsername = "example"
mailPassword = "example"

Call sendEmail(mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword)
end if %>

Edit #1: This is my hidden field (I’ve also put the hidden field after the submit button to no avail.)

<input type="hidden" name="isSubmitted" id="isSubmitted" value="yes" /> 
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="submit" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:51:22+00:00Added an answer on June 11, 2026 at 10:51 am

    Are you sure your form is doing a POST and not a GET ?
    If it’s a GET request, you would need request.querystring(“isSubmitted”) instead

    I would also put the check in a function.

    Function IsSubmit()
        'IsSubmit= (request.form("isSubmitted") = "yes") 'Edited for more generic solution
        IsSubmit = (Request.ServerVariables("REQUEST_METHOD") = "POST")
    End Function
    

    Then you can use __ if IsSubmit() then __ in your code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple code, using Joda-time. Works fine, but I have a problem.
This seems like a simple problem: I have a WF4 activity that guides the
I've wrote this simple piece of code. And I have a slight problem with
I have this simple code to test that a DB is ready: Function testlocalcon()
I have this simple problem. I'll try to explain with a sample code An
file = [file1,file2,...].join( ) `paste #{file}` Hello, I have this simple problem that has
this seems like a simple problem. I have a canvas application that I am
I have this simple problem that gets an input from the user using a
I have a simple problem with XML got from database. Now, this XML can
I'm guessing this is a simple problem, but I'm just learning... I have this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.