Hi,
I am very new to Smart Basic. I dabbled a few years ago, but didn't really have a problem to solve so didn't have much motivation to learn - and was also very busy!!
However, I now have a need for a custom apps, so am trying again.
I just wondered if it was possible to send an email from within your code?
Once my program has calculated and generated output, I'd like to send the results directly to an email address. Do you know if this is possible please?
Any help much appreciated.
Many thanks,
Paul.
Email from within a program
-
- Posts: 19
- Joined: Mon Jan 21, 2019 9:27 pm
- My devices: iPhone SE
- Flag:
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Email from within a program
Yes, I posted a program with that feature last April, called SB Notes.
viewtopic.php?f=20&t=2179
Check it out, and look for the action that occurs when the Mail button is pressed. You can copy the code from that section.
Let me know if you need further help.
Oh yes, Happy New Year, and welcome to the Forum.
viewtopic.php?f=20&t=2179
Check it out, and look for the action that occurs when the Mail button is pressed. You can copy the code from that section.
Let me know if you need further help.
Oh yes, Happy New Year, and welcome to the Forum.
The only thing that gets me down is gravity...
- GeorgeMcGinn
- Posts: 435
- Joined: Sat Sep 10, 2016 6:37 am
- My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10 - Location: Venice, FL
- Flag:
- Contact:
Re: Email from within a program
Ever since my last post (I had a real rough several months after I moved) so I was in no condition to really evaluate it, but afterwards I have had the time and this is the best programs on how to create and send marked-up HTML emails, where if you tried to do this in the iCloud email App, you cannot do many of the things this program does.
This one (SB Notes) is a keeper. Version 1.1 is a souped up version of the first version, but both preform creating the emails the same. I think the first version was an attempt to print from SmartBASIC by using an email address that may be directed to a printer (at least that is what it looks like).
This one (SB Notes) is a keeper. Version 1.1 is a souped up version of the first version, but both preform creating the emails the same. I think the first version was an attempt to print from SmartBASIC by using an email address that may be directed to a printer (at least that is what it looks like).
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
-
- Posts: 19
- Joined: Mon Jan 21, 2019 9:27 pm
- My devices: iPhone SE
- Flag:
Re: Email from within a program
Thanks for this link RBytes.
I must admit, I was expecting it to be a bit simpler than this - I'm going to have to really study your code to get to the nitty gritty bits that do the actual sending, as I only really want to send a simple string to a single email address. Plain text, no images or formatting etc...
I recall using TechBasic at some point and assumed it would be a similar approach in SB (e.g. something like system.newEmail("xxxx@yahoo.co.uk"),message$
Nevermind, I love SB now, so I'll persevere!
Many thanks
I must admit, I was expecting it to be a bit simpler than this - I'm going to have to really study your code to get to the nitty gritty bits that do the actual sending, as I only really want to send a simple string to a single email address. Plain text, no images or formatting etc...
I recall using TechBasic at some point and assumed it would be a similar approach in SB (e.g. something like system.newEmail("xxxx@yahoo.co.uk"),message$
Nevermind, I love SB now, so I'll persevere!
Many thanks
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Email from within a program
The technique requires more than just a single line of code, because it calls JavaScript in a Smart Basic browser window. But no need to reinvent the wheel. Everything you need is here.
Try this code. Substitute your own choice of email, subject and body in the first 3 lines. Then run the program. It will open a new Mail message with the address, subject and body, all ready to press Send.
Try this code. Substitute your own choice of email, subject and body in the first 3 lines. Then run the program. It will open a new Mail message with the address, subject and body, all ready to press Send.
Code: Select all
email$="somebody@somewhere.ca"
subject$="Your Kijiji ad"
body$="I am interested in your 76 Mustang. Will you negotiate on the price?"
a1$="<html><head><script type="&q$&"text/javascript"&q$&"> function mymessage() { location.href="
a1a$=CHR$(34)&"mailto:"
a1b$=email$!a1c$="?subject="
a2$=subject$
a3$="&body="
a4$=body$
a5$=CHR$(34)&";} </script></head><body onload="&q$&"mymessage()"&q$&"></body></html>"
a$=a1$&a1a$&a1b$&a1c$&a2$&a3$&a4$&a5$
BROWSER "n" AT 0,0 SIZE 100,100
BROWSER "n" TEXT a$
end
The only thing that gets me down is gravity...
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Email from within a program
Can you actually send the email from within the SB program without touching the "send" button? That would be a nice feature to mail a selected group of contacts from a contacts base.
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Email from within a program
I haven't found a way to do that yet. It might be possible with JavaScript, so I will keep looking.
The only thing that gets me down is gravity...
-
- Posts: 19
- Joined: Mon Jan 21, 2019 9:27 pm
- My devices: iPhone SE
- Flag:
Re: Email from within a program
Hi,
Thank you so much for this! I must admit, I don't really understand the code but it is doing exactly what I wanted so it's very helpful, and much appreciated.
Thank you so much for this! I must admit, I don't really understand the code but it is doing exactly what I wanted so it's very helpful, and much appreciated.
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Email from within a program
You're welcome, Paul. The code does look confusing at first. Basically, you have to construct a short HTML web page that will call a JavaScript email command. The structure of the page never changes, but some of the elements do - the email address, the subject and the body (contents). So I make each element a text string. Once the user inserts the three variable elements, I reassemble the strings to create the complete page.
Try adding the line PRINT a$ at the end of the program and you will see the complete HTML page.
Try adding the line PRINT a$ at the end of the program and you will see the complete HTML page.
The only thing that gets me down is gravity...
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Email from within a program
Paul, I just posted a new topic called The End of Smart Basic? in Other Topics.
You mentioned that you might be using it in a new project. You and other new users need to be aware of the current shaky status of Smart Basic, and not put unrealistic hopes on it. If the success of your project will affect either your finances or your career success, please read my post ASAP.
You mentioned that you might be using it in a new project. You and other new users need to be aware of the current shaky status of Smart Basic, and not put unrealistic hopes on it. If the success of your project will affect either your finances or your career success, please read my post ASAP.
The only thing that gets me down is gravity...