Email completed form (active Word document) by pressing 'Submit' command button (1 Viewer)

PeteB

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2016
Messages
78
I've created a single page Word form using Developer text controls which is to be put on to our website and serve as a membership application form but, not being code-savvy, I'm finding picking through the different sets of VB code offered to get the job done to be a nightmare. The code will be activated by said Submit button and must achieve the following: -
  1. Send the completed form to nominated e-mail address (from any e-mail client);
  2. Return an e-mail confirming receipt of the application and thank you;
  3. Redirect the submitter of the form to another website (our payment gateway).
I would appreciate AWF assistance. Please assume that my knowledge is basic (unambiguous stepped instructions please).
Thanks.
PeteB
 

conception_native_0123

Well-known member
Local time
Today, 12:10
Joined
Mar 13, 2021
Messages
1,826
I'm finding picking through the different sets of VB code offered to get the job done to be a nightmare. The code will be activated by said Submit button and must achieve the following: -
the VBA code will be activated by a submit button? a form that belongs to the word application does not belong on a web server in general. i don't think anyway. there are many different ways to use office products, but if you want to go through this process using web-based code, HTML, javascript and any server side code would be more appropriate than microsoft word. am i reading your words correctly?

any code can do this, along with step 3 which is nothing more than a redirect. for instance, the header() function in PHP or redirect() method in c#.
 

PeteB

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2016
Messages
78
Thank you for above response. I think you are reading my words correctly. Your response however does lead me to further queries.
  1. Why would Microsoft build into Word the functionality of Developer field controls if a form created using them was not then apprpriate to be on a web server?
  2. I am not familiar with 'server side code';
  3. I have come across PHP but am not familiar with its functionality, or that of redirects;
  4. What is the significance of 'c#' in your last sentence?
I would appreciate it if you could expand on the above.

Many thanks

PeteB
 

conception_native_0123

Well-known member
Local time
Today, 12:10
Joined
Mar 13, 2021
Messages
1,826
I would appreciate it if you could expand on the above.

would be my pleasure...

  1. Why would Microsoft build into Word the functionality of Developer field controls if a form created using them was not then apprpriate to be on a web server?

because many programs are like this but are generally not designed for web use because they were not created for the purpose of web use to begin with. with regard to ms word, developer controls are included and available inside the program in order to help the developer create user-friendly applications or documents. but that doesn't necessarily mean they are meant to be web-based documents. you could think of things like "docusign" as a web-based alternative to microsoft documents on the web.

  1. I am not familiar with 'server side code';

web-based applications are currently split between 2 types of code. server-side and client-side. that's the standard for 90% of the web. more than likely, that will completely change within 10-30 years and "all code" that runs on the web will be placed into one "bucket" which will not be classified as either "server side" or "client side". It will just run as a "one off" where everything basically communicates at the same time. the current process that describes this coming to pass is called "asynchronous activity" or "asynchronous querying".

  1. I have come across PHP but am not familiar with its functionality, or that of redirects;

every server side coding language (and most types of javascript code) can issue re-directs. below is a small example that is stored on one of my sites, and I put it on a test site for you to take a look at, that issues a re-direct to the domain's homepage after the form submit button is pressed. Press the button on the following page to see the re-direct happen from execution of the simplest javascript function possible: https://www.adamevanovich.com/test/

  1. What is the significance of 'c#' in your last sentence?

c# is a server side language. one of many. the function I mentioned in my last sentence also serves the same purpose as the example I posted for you above: https://docs.microsoft.com/en-us/dotnet/api/system.web.httpresponse.redirect

I also mentioned PHP's similar function called "header". Its doc is here: https://www.php.net/manual/en/function.header.php

I realize that those docs are very complex to understand, but I just included them for you as a reference. :)
 

PeteB

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2016
Messages
78
Thanks for explanation - that should keep me busy for a while.

PeteB
 

conception_native_0123

Well-known member
Local time
Today, 12:10
Joined
Mar 13, 2021
Messages
1,826
Thanks for explanation - that should keep me busy for a while.

well it wasn't meant to keep you busy Pete. sorry if I went overboard. that might be a little more than you need. let everyone here know if you need more help. that's what people are here for. I think anyway!
 

Isaac

Lifelong Learner
Local time
Today, 10:10
Joined
Mar 14, 2017
Messages
8,738
Look into using CDO code with VBA in Word connected with your own Gmail account in order to send both emails.
 

PeteB

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2016
Messages
78
Hi Isaac

Thanks for your advice.

When looking for CDO code, I came across Microsoft Visual Studio which apparently covers various coding systems. Who new there were so many?

Still haven't found a solution that I can make work.

Thanks again.

PeteB
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:10
Joined
Sep 21, 2011
Messages
14,044
Search here for CDO and username isladogs.

That has all the code you need to make it work.
 

PeteB

Registered User.
Local time
Today, 10:10
Joined
Mar 15, 2016
Messages
78
Thanks Gasman

I've looked at the site you suggest but am not sure how it relates to what I'm trying to achieve. I couldn't find any relevant code.

PeteB
 

conception_native_0123

Well-known member
Local time
Today, 12:10
Joined
Mar 13, 2021
Messages
1,826
I've looked at the site you suggest but am not sure how it relates to what I'm trying to achieve. I couldn't find any relevant code.
this is probably what he's trying to show you:


but it is fairly complicated. CDO isn't the easiest library to use. its purpose, unless i'm mistaken, it to use an outside email client to send messages through the windows OS. I'm sure the guys were telling you about CDO because you wanted to send a form through email. I gave the advice I did because you said something about putting information on a webpage. webpages are not necessary to use CDO libraries.

When looking for CDO code, I came across Microsoft Visual Studio which apparently covers various coding systems. Who new there were so many?

vs covers almost everything. it's called an IDE. you do not need that to perform a simple task like this. that's for very advanced initiatives outside of ms office VBA.
 

Isaac

Lifelong Learner
Local time
Today, 10:10
Joined
Mar 14, 2017
Messages
8,738
CDO is very easy to use in VBA and there are many examples. where I have found it challenging is that occasionally it will return vague errors that are a little bit difficult to isolate the cause for and troubleshoot, but as the last couple posters have mentioned, we have a few experts on this forum. you do not need visual studio to use it, once again, CDO and VBA.
 

isladogs

MVP / VIP
Local time
Today, 17:10
Joined
Jan 14, 2017
Messages
18,186
I also think CDO is very straightforward to use.
its purpose is to send emails direct from e.g. Access without needing to involve an external email app such as Outlook (or any other program).

I have created an example Access app with all code necessary to use it. See EMail Tester - Mendip Data Systems
It also includes a help file which explains what any error messages mean and how to fix them.

You will need to know the account settings for your email address which you can get from Outlook or even your phone
 

conception_native_0123

Well-known member
Local time
Today, 12:10
Joined
Mar 13, 2021
Messages
1,826
Suggest you read about what it actually does mean. This may help you get the idea: VBA - CDO Mail | DEVelopers HUT (devhut.net)
I remember an attempt to use this a long time ago colin. If I remember right, I never did get it to work although it was close. But this has been so many years ago I don't even remember anymore. And it just may happen that the page you linked to is the page I actually looked at. Don't remember that either.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:10
Joined
Feb 28, 2001
Messages
26,999
Let's go theoretical for a brief moment. CDO is a very simple but very effective facility for Access (or in fact, any other VBA-using utility) to send mail. The question was asked about whether CDO works with GMail or other outside clients. The answer is "No, it does not need to."

Outgoing mail is, for most of the internet, sent via a protocol called SMTP - whether we are talking CDO or Outlook or something else. Though it has extensions for binary attachments, SMTP or "Simple Mail Transfer Protocol" is actually just a literal text protocol. It does not need to have a local client like Outlook or Thunderbird or whatever other local mail clients might be out there. Instead, when you use CDO, you supply the destination address in a "username@web-path" format - where the web path is a computer name and the other part is the targeted recipient of the mail. And that "other part" has to be the name of the person on the destination system. So what happens with CDO?

Like any machine on a network that has some kind of ISP router or domain controller (either one, or both), there is an address defined on your machine as your "SMTP Gateway." What happens is you don't send your mail to the "web-path" in your destination address. Instead, you send your mail to the gateway and the gateway device will do the rest. All that CDO has to do is open a network link (socket) to the gateway and say "HELO" to port 23 of the gateway machine. Then it starts the protocol with "SEND" (yes, literally those letters in that order). When the gateway responds, CDO sends "TO username@web-path" - and there are other parts of the protocol for attachments, subject line, CC and BCC, and stuff like that. CDO formats the text it has to send to the gateway, then using the link it just opened (to the gateway), it crams the mail message down that pipeline.

When the mail message is still initially being received at the gateway, that system looks up the "TO:" address and determines a proper route. If a route is determined by the gateway, it pushes the message along. OR if there is a problem, an error is returned in reply to the TO: part of the transmission. So all that CDO has to do is test for a success or failure code on the reply from the gateway. You get a success? Keep on sending. You get a failure? Report it to the user and clean up the mess.

If you have ever heard the term "Store and Forward" in the context of the Internet, this is a PERFECT example of a Store and Forward protocol. And because it is so simple, CDO can do those steps without the help of a mail utility.

Note that RECEIVING a message is a bit more complex and uses a totally different protocol. You usually need a mail client for this function. CDO does not include the required reception protocols. This is why you can use CDO to send mail but not to receive it.
 

Users who are viewing this thread

Top Bottom