#1 2017-02-27 07:15:46

Romeo Ross
Member
From: Johannesburg
Registered: 2017-02-12
Posts: 9

HTTPClient & Simplepost to send emails from our apps

Hi David

Thank you for your great product.

Is there s possibility that you can create a sample where the all the input information be sent to a specific email address and not just give an alert saying it was successful.

For someone with your talents I am sure you will be able to assist, I have been trying for days how to do this but for a non-programmer this is a difficult job.

Thank you once again.

Last edited by Romeo Ross (2017-02-27 08:14:45)

Offline

#2 2017-02-27 10:15:44

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

Thanks for your kindly words. I certainly think that your issue is related with the ability to send emails from our applications: we simply can't do that from our applications nor from any other Javascript based application: we can't send emails from Javascript, except using a thirdparty online service.

However the server side yes, can send emails, then, what we can do is certainly an HTTP request to some script in our server in order to send the email we wanted. If you are using PHP in the server side, for example, they offers to us the well named "mail" function.

So what we must do is the following:

  1. In our application prepare an HTTP POST request to be made with the HttpClient control.

  2. The request must contains the recipient email address, the email subject, the email body and more (if needed).

  3. In the server side, we deal with the received request and pick the appropiate input: email address, subject, etc.

  4. That's all. The server side script, for example, PHP, call to the "mail" function in order to send the email.

In fact I start to work here in a sample for you, but, when I almost finished the PHP script... I just remember that the Calculator application sample already incorporates an script like that for their "Feedback" view. So you can take a look at that sample too.

But, since I almost finished the PHP script... and the application sample can take not too much time (thanks AB!) I want to prepare a sample for you specifically designed to send emails from the application.

So please, upgrade your App Builder copy and take a look at the new "SendEmail" sample.

Q4fNBmr.gif

Then tell me what do you think about Romeo!

Offline

#3 2017-02-27 10:21:47

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello again,

I think I forget something... you talking about the "SimplePost" action and the "HttpClient" control. Can we use the "SimplePost" action to send emails instead of the HttpClient control? Yes, of course, and also the "SimpleGet" action.

However, this actions doesn't provide us any feedback about the request, then, probably it's a good idea to use an HttpClient control, like in the "SendEmail" sample, then we get informed if the task is successfully executed or what.

Offline

#4 2017-02-27 10:36:19

Romeo Ross
Member
From: Johannesburg
Registered: 2017-02-12
Posts: 9

Re: HTTPClient & Simplepost to send emails from our apps

David thank you so much for the great sample, it is amazing how fast you respond and help to solve problems.

Offline

#5 2017-02-27 10:42:11

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

Romeo Ross wrote:

David thank you so much for the great sample, it is amazing how fast you respond and help to solve problems.

You're welcome! Hope you find it useful!

Offline

#6 2017-02-28 07:06:40

Romeo Ross
Member
From: Johannesburg
Registered: 2017-02-12
Posts: 9

Re: HTTPClient & Simplepost to send emails from our apps

Morning David the sample works perfect and I even managed to add an extra inputbox for a phone number into the sample and then added that extra code into to the PHP file to include it. Is there a way you can add in a drop drop selection as well?

I want to receive the dropdown selection information in the email as well. but don't know how to add that in ,especially in the PHP file.

Please see my sample picture. Thank you very much.

pick.png

Offline

#7 2017-02-28 08:11:42

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

The Select control, as well others controls, store their items in an Array variable. You can take a look at the "Select" and "Select2" app samples. Now supose we have a Select control named "MySelect", then we can get their selected item with a code like the below one:

ArrayGetItem "[MySelect.Items]" "[MySelect.ItemIndex]" "[SelectedItem]"

The variable "[SelectedItem]" stores the selected item text, then, we can add it to the HTTP request in a way like the below one:

HttpSetData "EmailHttpClient" "UserSelection" "[SelectedItem]"

If you remember the other fields in the send email request:

HttpSetData "EmailHttpClient" "EmailBody" "[EmailBodyTextarea.Value]"
HttpSetData "EmailHttpClient" "EmailSubject" "[EmailSubjectInput.Value]"
HttpSetData "EmailHttpClient" "EmailAddress" "[EmailAddressInput.Value]"

... we can access to this field by their "keys/identifiers" in the server side, so, you know we can access to "EmailBody", "EmailSubject" and "EmailAddress" in the server side.

We can add any number of keys/identifiers and values pairs in our request, then, after this:

HttpSetData "EmailHttpClient" "UserSelection" "[SelectedItem]"

... we can also access in the server side to the "UserSelection" input, in the same way than all the others: "EmailBody", "EmailSubject", etc.

Offline

#8 2017-03-01 22:42:41

Romeo Ross
Member
From: Johannesburg
Registered: 2017-02-12
Posts: 9

Re: HTTPClient & Simplepost to send emails from our apps

Hi David

Thank you very much...

I follow exactly as above but still cant get right after two days.

The email sends successfully, I get ALL the  input info but the selected ''ArrayGetItem'' is no where in email I receive.

Please can I ask you to put in sample and the sendemail.php if you don't mind.

Apologies for all the questions.

Offline

#9 2017-03-01 22:58:29

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

I am not now in my PC, but, I will to enhance the "SendEmail" sample tomorrow in order to incorporate a "Select" control. And please, you no need go apologize for anything. Just ask whatever you needed and here we try to help as best as possible.

Offline

#10 2017-03-02 09:42:39

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

Please, upgrade your AB copy: the SendEmail sample has been enhanced in order to use also a Select control. I think you get into problems (maybe I am wrong) because before the "EmailBody" input is directly used (after their validation) in the PHP's "mail" function. As you can see in the new SendEmail sample, we conform an email body using the "EmailBody" input and the introduced value from the Select control. Take a look and tell me if you got it!

Offline

#11 2017-03-02 19:04:40

Romeo Ross
Member
From: Johannesburg
Registered: 2017-02-12
Posts: 9

Re: HTTPClient & Simplepost to send emails from our apps

Its works :-) Thank you

Offline

#12 2017-03-02 19:05:13

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: HTTPClient & Simplepost to send emails from our apps

Hello Romeo,

Romeo Ross wrote:

Its works :-) Thank you

You're welcome!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.