Liberty BASIC Community Forum
« Send email, with optional attachments. »

Welcome Guest. Please Login or Register.
Sep 19th, 2017, 1:52pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Send email, with optional attachments.  (Read 1947 times)
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Send email, with optional attachments.
« Reply #15 on: Feb 22nd, 2013, 03:34am »

Try dropping the -a since you don't specify an attachment.

Code:
cmd$ = " -f ";from$;" -t ";recipient$;" -s ";server$;" -xu ";mailuser$;" -xp ";mailpwd$;" -u ";message$ 


The rest of it looks to be correct.
User IP Logged

andy1977
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 22
xx Re: Send email, with optional attachments.
« Reply #16 on: Feb 22nd, 2013, 3:13pm »

Thanks for the reply. That definitely makes sense, so I have corrected the error.

Code:
'Example to send email using gmail.
'For other services, see their documentation

'requires sendemail.exe and sendemail.pl

from$ = "andrewraab@btinternet.com"
mailuser$ ="andrewraab@btinternet.com"
recipient$ ="jemmaraab@btinternet.com"
server$ = "mail.btinternet.com:25"           '465 of 587
mailpwd$ = "**********"
subject$ = "howdy"
message$ = "test 123"


cmd$ = " -f ";from$;" -t ";recipient$;" -s ";server$;" -xu ";mailuser$;" -xp ";mailpwd$;" -u ";message$

run "C:\sendEmail\sendEmail.exe ";cmd$ , Hide

end 


Unfortunately I am still getting the error, "Runtime error: Out of memory". Below is the error log, If you don't mind, and have the time to have a look. Thanks (I didn't put in the smiley faces lol)
Code:
Error log timestamp Friday 22/02/13 20:50:20

Runtime error: out of memory

Error(Exception)>>defaultAction
Error(Exception)>>activateHandler: <anUndefinedObject> 
Error(Exception)>>handle
Error(Exception)>>signal
Error class(Exception class)>>signal: <'out of memory'> 
BasicProgram(Object)>>error: <'out of memory'> 
BasicProgram>>terminateRun: <anError> 
[] in BasicProgram>>errorHandlerBlock
ExceptionHandler>>evaluateResponseBlock: <aBlockClosure> for: <anError> 
[] in ExceptionHandler>>handle:
ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> 
BlockClosure>>invisibleEnsure: <aBlockClosure> 
ExceptionHandler>>handle: <anError> 
ExceptionHandler>>findHandler: <anError> 
Error(Exception)>>activateHandler: <anExceptionHandler> 
Error(Exception)>>handle
Error(Exception)>>signal
Error class(Exception class)>>signal: <'out of memory'> 
BasicProgram(Object)>>error: <'out of memory'> 
[] in RunCommand>>using:
[] in BasicProgram>>begin
ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> 
[] in ExceptionHandler>>activateDuring:
ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> 
BlockClosure>>invisibleEnsure: <aBlockClosure> 
ExceptionHandler>>activateDuring: <aBlockClosure> 
ExceptionHandler class>>handle: <anError class> with: <aBlockClosure> during: <aBlockClosure> 
BlockClosure>>on: <anError class> do: <aBlockClosure> 
BasicProgram>>begin
BasicProgram>>run
[] in BasicSourcePane>>run
BasicCompiler class>>compileFromString: <'
''Example to send e...'> notify: <aBasicSourcePane> ifSuccess: <aBlockClosure> 
BasicSourcePane>>run
BasicSourceWindow>>run
BasicEditorModel>>run: <aToolbarButton> 
BasicEditorModel(Object)>>perform: <#run:> with: <aToolbarButton> 
ToolbarButton>>triggerClickedEvent
Message>>perform
NotificationManager>>runPendingEvents
NotificationManager>>runEventLoop
Message>>perform
Message>>evaluate
Process>>safelyEvaluate: <aMessage> 
Process>>evaluate: <aMessage> 
 

« Last Edit: Feb 24th, 2013, 09:43am by Stefan Pendl » User IP Logged

Mattestion
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 154
xx Re: Send email, with optional attachments.
« Reply #17 on: Feb 22nd, 2013, 3:39pm »

Nothing in the code you supplied should be giving an out of memory error. It could be something other than LB causing the problem. Have you tried restarting your computer? This will clear the memory and perhaps resolve the problem.
User IP Logged

Just BASIC v1.01 / Liberty BASIC Pro v4.04 / Run BASIC v1.01 / Windows 10 - AMD A10-6700T APU - Radeon HD 8650D - 2.50GHz - 8GB RAM
andy1977
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 22
xx Re: Send email, with optional attachments.
« Reply #18 on: Feb 22nd, 2013, 5:08pm »

Getting closer, I think I may have downloaded the wrong sendemail files. I got them from this site: http://caspian.dotconf.net/menu/Software/SendEmail/

and was downloading the 'official' files. Just noticed the files for windows, with TLS Support, downloaded, and now, no more errors. Still struggling to get anything sent through though. Earlier in this thread, someone was successful in sending from a Gmail account, so have now changed my 'from e-mail address', to a gmail.
and got the smtp details from here:
http://www.emailaddressmanager.com/tips/mail-settings.html

Code:
 from$ = "andrewstuartraab@gmail.com"
mailuser$ ="andrewstuartraab@gmail.com"
recipient$ ="andrewraab@btinternet.com"
server$ = "smtp.gmail.com:587"           '465 of 587
mailpwd$ = "*******"
subject$ = "howdy"
message$ = "test 123"


cmd$ = " -f ";from$;" -t ";recipient$;" -s ";server$;" -xu ";mailuser$;" -xp ";mailpwd$;" -u ";message$

run "C:\sendEmail\sendEmail.exe ";cmd$ , Hide

end
 


I would like to say a big thank you, to everyone that is taking the time and effort to reply. I do really appreciate it.
User IP Logged

Mattestion
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 154
xx Re: Send email, with optional attachments.
« Reply #19 on: Feb 22nd, 2013, 5:23pm »

I just remembered that this was recently discussed on the JB forums. See this thread: SENDEMAIL USAGE PROBLEMS

BTW, Reply #7 in that thread has the correct Gmail settings.
User IP Logged

Just BASIC v1.01 / Liberty BASIC Pro v4.04 / Run BASIC v1.01 / Windows 10 - AMD A10-6700T APU - Radeon HD 8650D - 2.50GHz - 8GB RAM
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Send email, with optional attachments.
« Reply #20 on: Feb 23rd, 2013, 03:48am »

Writing the .log file would seem to be the fastest way to get to the root of the problem. John shows how in the rosetta code example.

http://rosettacode.org/wiki/Send_email#Liberty_BASIC
User IP Logged

andy1977
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 22
xx Re: Send email, with optional attachments.
« Reply #21 on: Feb 23rd, 2013, 8:12pm »

Just wanted to let you know, that thanks to your help, tips, and clues in the right direction, I have got it to work. Although not from my btinternet account as planned, but from a gmail account I created in place. It's working, so not going to play around with it lol.

There is just one more query though, and having looked through the forums, I don't think it has been asked. In the main body of the message, I can get my text, but was wondering if part way through, if there was a way to start on a new line for text, like a start of a new paragraph?

Normally for printing on paper, or on screen, I know the lprint command on each new line, but realise this doesn't apply in this case.

If it hasn't already become apparent, I bit of a novice to programming.
User IP Logged

Mattestion
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 154
xx Re: Send email, with optional attachments.
« Reply #22 on: Feb 23rd, 2013, 8:57pm »

I believe you would need to use the CRLF character (Carriage Return + Line Feed). It's actually a combination of two characters represented as 13 and 10 on the ASCII chart. So for your message you would have something like this: paragraph1$ + chr$(13) + chr$(10) + paragraph2$. Actually I believe to have a blank line between paragraphs you would need two CRLF.
User IP Logged

Just BASIC v1.01 / Liberty BASIC Pro v4.04 / Run BASIC v1.01 / Windows 10 - AMD A10-6700T APU - Radeon HD 8650D - 2.50GHz - 8GB RAM
Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: Send email, with optional attachments.
« Reply #23 on: Feb 24th, 2013, 09:48am »

SendEmail offers the ability to use the contents of a file as the body with a different command line switch.

So remove the body from the command line and use a body file instead.

The command line is only good for simple messages, like one-liners, more complex ones should be saved to a file anyways.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Brandon Parker
Board Moderator

member is offline

Avatar




PM

Gender: Male
Posts: 1115
xx Re: Send email, with optional attachments.
« Reply #24 on: Feb 24th, 2013, 7:06pm »

on Feb 24th, 2013, 09:48am, Stefan Pendl wrote:
The command line is only good for simple messages, like one-liners, more complex ones should be saved to a file anyways.


I'm not saying not to use a file for the body, but if you build your body in the program correctly sendEmail will have no problem sending all of the string you give it for the body through the command line. I currently utilize this method for constructing/ sending e-mails out as alerts for a group in my company.

Either way is correct as long as you format it correctly.....


{:0)

Brandon
« Last Edit: Aug 6th, 2013, 8:16pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: Send email, with optional attachments.
« Reply #25 on: Feb 25th, 2013, 2:57pm »

The length of the command line is limited, so using files for long strings is rational.

The command line limitation is laid on us by Windows, so there is nothing we can do to overcome it.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Rui Branco
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 370
xx Re: Send email, with optional attachments.
« Reply #26 on: Jan 14th, 2014, 11:59am »

Something changed in gmail service, now we need TLS to send email with this code.
Can anyone confirm?
User IP Logged

https://plus.google.com/u/0/111683094753659065762/about
Rui Branco
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 370
xx Re: Send email, with optional attachments.
« Reply #27 on: Jan 14th, 2014, 12:28pm »

Code:
text$       = "This is a simple text message."
tls$        = "tls=yes"
from$       = "xx@gmail.com"
username$   = "xx@gmail.com"
password$   = "xxx"
recipient$  = "xx@gmail.com"
server$     = "smtp.gmail.com:587"
subject$    = chr$( 34) +text$          +chr$( 34)  '   Use quotes to allow spaces in text.
message$    = chr$( 34) +"Hello world." +chr$( 34)
attach$     = "CHANGELOG.txt"
logfile$    = "sendemail.log"

cmd$ = " -o ";  tls$;_
       " -f ";  from$;_             'from
       " -t ";  recipient$;_        'to
       " -u ";  subject$;_          'subject
       " -s ";  server$;_           'server
       " -m ";  message$;_          'message
       " -a ";  attach$;_           'file to attach
       " -l ";  logfile$;_          'file to log result in
       " -xu "; username$;_         'smtp user name
       " -xp "; password$           'smtp password not given so will ask in a CMD window

run "sendEmail.exe "; cmd$, HIDE

end

 


output
Jan 14 18:24:33 x-pc sendEmail.exe[8076]: ERROR => No TLS support! SendEmail can't load required libraries. (try installing Net::SSLeay and IO::Socket::SSL)
« Last Edit: Jan 14th, 2014, 5:41pm by Rui Branco » User IP Logged

https://plus.google.com/u/0/111683094753659065762/about
Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5295
xx Re: Send email, with optional attachments.
« Reply #28 on: Jan 14th, 2014, 6:09pm »

SendEmail does support TLS, but it is a separate download.

Also make sure to have the latest SendEmail.exe downloaded from the original home page at http://caspian.dotconf.net/menu/Software/SendEmail/
Also check out the TLS support section of the download page, which tells you what you need to install in addition.
User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
andy1977
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 22
xx Re: Send email, with optional attachments.
« Reply #29 on: Jan 18th, 2014, 5:39pm »

Thanks for the heads-up on that. I'm still using my original program from a year ago, which seems to be still working fine with e-mails, so thinking I may already be using the TLS. (I hope so anyway, I still remember the headache it gave me last time to get it working)
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls