|
Post by Chris Iverson on Sept 3, 2021 9:34:01 GMT -5
It's a separate program, but you can distribute it with your program, and if you call it like the code they provided, it will send the email automatically, without intervention from the user.
It is different from the example code you have posted, which simply calls the user's default email client, requiring them to manually send the email.
|
|
|
Post by metro on Sept 3, 2021 13:31:19 GMT -5
|
|
|
Post by Brandon Parker on Sept 3, 2021 14:26:57 GMT -5
IMO, I would steer away from the SendEmail linked to by metro (no offense). It requires the .NET Framework 4.8 to work. Newer versions of Windows typically install this, but if not then you would have to either have the user download/install it or figure out how to do it programmatically. Also, there might be changes to the framework that prevents the program from running in the future since we all know that Microsoft has a tendency to just discontinue certain things at will due to security risks Maybe it's just me, but the .NET framework is just a pain to rely on... {:0) Brandon Parker
|
|
curly
Full Member
Posts: 161
|
Post by curly on Sept 5, 2021 4:05:54 GMT -5
Hi again,
This code if lifted direct from my application with just the password changed. The log identified issues which I corrected as each one was flagged up. The log now contains nothing, by stepping in through the debugger window it goes through each line without a problem, but the email never arrives. You know now I'm a novice, but can you please look at my code to see what I have wrong? It's driving me nuts!
Kind regards, David
[EmailFile] 'This program requires sendemail.exe and sendemail.pl in the same directory, ' available free from Caspian's SendEmail Site. TLS version also available. 'Commandline Switches: ' Required: ' -f ADDRESS from (sender) email address ' At least one recipient required via -t, -cc, or -bcc ' Message body required via -m, STDIN, or -o message-file=FILE ' Common: ' -t ADDRESS [ADDR ...] to email address(es) ' -u SUBJECT message subject ' -m MESSAGE message body ' -s SERVER [:PORT] ' Optional: ' -a FILE [FILE ...] file attachment(s) ' -cc ADDRESS [ADDR ...] cc email address(es) ' -bcc ADDRESS [ADDR ...] bcc email address(es) ' -xu USERNAME username for SMTP authentication ' -xp PASSWORD password for SMTP authentication
from$ = "maddy@ukgo.com" username$ = "maddy@ukgo.com" password$ = "xxxxxxxx" recipient$ = "madanddave@virginmedia.com" server$ = "smtp.freeolamail.net: 587"
subject$ = "Plain text" message$ = "Hoorah or Oh, bugger!"
attach$ = "C:\ProgramData\test.csv" logfile$ = "sendemail.log"
'[openAddresses] ' filedialog "Open address file for processing", "*.txt; *.csv", fname$ ' if fname$ ="" then goto [openAddresses]
' open fname$ for input as #addressFile
' pathLength =len( DefaultDir$)
' print "Sending e-mails to addresses held in "; mid$( fname$, pathLength +2)
' while eof( #addressFile) <>-1 ' input #addressFile, recipient$ cmd$ =_ " -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 ' print " "; recipient$ 'Delay 5 seconds before sending another email print "sendEmail.exe"; cmd$ ' calldll #kernel32, "Sleep", 5000 as ulong, r as void ' wend
' close #addressFile ' print "All sent. Done." goto [CircuitSchedulesWait]
|
|
|
Post by tenochtitlanuk on Sept 5, 2021 9:24:23 GMT -5
I edited the code to use my server and it ran happily for me.... BUT.... -you didn't notice, I suspect, my earlier comment that you need to surround subject and message string with quotes signs ( ") which is chr$( 34).
subject$ = chr$( 34) +"Plain text" +chr$( 34) message$ =chr$( 34) +"Hoorah or Oh, bugger!" +chr$( 34)
Try it again with these two lines corrected as above...
|
|
curly
Full Member
Posts: 161
|
Post by curly on Sept 6, 2021 4:25:42 GMT -5
Hi,
Still no go. My outgoing server says it requires password authentication. I assume the inclusion of a password satisfies that?
The code shows how it is now excluding my password. Kind regards, David
[EmailFile] 'This program requires sendemail.exe and sendemail.pl in the same directory, ' available free from Caspian's SendEmail Site. TLS version also available. 'Commandline Switches: ' Required: ' -f ADDRESS from (sender) email address ' At least one recipient required via -t, -cc, or -bcc ' Message body required via -m, STDIN, or -o message-file=FILE ' Common: ' -t ADDRESS [ADDR ...] to email address(es) ' -u SUBJECT message subject ' -m MESSAGE message body ' -s SERVER [:PORT] ' Optional: ' -a FILE [FILE ...] file attachment(s) ' -cc ADDRESS [ADDR ...] cc email address(es) ' -bcc ADDRESS [ADDR ...] bcc email address(es) ' -xu USERNAME username for SMTP authentication ' -xp PASSWORD password for SMTP authentication
from$ = "maddy@ukgo.com" username$ = "maddy@ukgo.com" password$ = "xxxxxxx" recipient$ = "madanddave@virginmedia.com" server$ = "smtp.freeolamail.net: 587"
subject$ = chr$(34)+ "Plain text" + chr$(34) message$ = chr$(34) + "Hoorah" +chr$(34)
attach$ = "C:ProgramData\test.csv" logfile$ = "sendemail.log"
'[openAddresses] ' filedialog "Open address file for processing", "*.txt; *.csv", fname$ ' if fname$ ="" then goto [openAddresses]
' open fname$ for input as #addressFile
' pathLength =len( DefaultDir$)
' print "Sending e-mails to addresses held in "; mid$( fname$, pathLength +2)
' while eof( #addressFile) <>-1 ' input #addressFile, recipient$ cmd$ =_ " -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 ' print " "; recipient$ 'Delay 5 seconds before sending another email print "sendEmail.exe"; cmd$ ' calldll #kernel32, "Sleep", 5000 as ulong, r as void ' wend
' close #addressFile ' print "All sent. Done." goto [CircuitSchedulesWait]
|
|
|
Post by metro on Sept 6, 2021 4:39:48 GMT -5
I have the same result here as John, I did find it somewhat confusing that some online resources suggested (as I am using Gmail) that I had to leave off the "@gmail.com" for the username$. but that was not the case. It worked for me with myusername@gmail.com Of course, it is not all smooth sailing Google does not like less secure programs so I had to set a new "app password" but after that ...., it just worked. maybe give username$ a go without the @ukgo.com PS
maybe copy and paste your current password from you email client's saved passwords to avoid typo's. mine for Gmail is quite confusing as it is generated by Google.
|
|
|
Post by tenochtitlanuk on Sept 6, 2021 10:11:22 GMT -5
As another possible trap, is it happy with the space in
server$ = "smtp.freeolamail.net: 587"
|
|
curly
Full Member
Posts: 161
|
Post by curly on Sept 7, 2021 12:18:03 GMT -5
Hi,
OK, finally got it working. No spaces allowed in the filepathand filename for attachments.
The maximum filepath plus filename limit in dos of 63 chars doesn't seem to apply.
Thank you all very much. Kind regards, David
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Jun 20, 2022 15:15:42 GMT -5
I get this errors with the code?
Error log timestamp Monday 20-06-22 22:11:50
Runtime error: Kan opgegeven module niet vinden. ( OS error 16r7E )
Error(Exception)>>defaultAction Error(Exception)>>activateHandler: <anUndefinedObject> Error(Exception)>>handle Error(Exception)>>signal Error class(Exception class)>>signal: <'Kan opgegeven module...'> BasicProgram(Object)>>error: <'Kan opgegeven module...'> 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: <'Kan opgegeven module...'> DynamicLinkLibrary class(Object)>>osError: <126> DynamicLinkLibrary class(Object)>>osError DynamicLinkLibrary class>>open: <'ftp4w32.dll'> BasicDLL>>from: <'ftp4w32.dll'> mode: <'DLL'> handle: <'#ftp'> BasicDLL class(BasicFile class)>>from: <'ftp4w32.dll'> mode: <'DLL'> handle: <'#ftp'> owner: <aBasicProgram> length: <anUndefinedObject> [] in OpenCommand>>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: <' nomainwin
di...'> notify: <aBasicSourcePane> ifSuccess: <aBlockClosure> BasicSourcePane>>run BasicSourceWindow>>run BasicEditorModel>>run: <aToolbarButton> ToolbarButton>>triggerClickedEvent Message>>perform NotificationManager>>runPendingEvents NotificationManager>>runEventLoop Message>>perform Message>>evaluate Process>>safelyEvaluate: <aMessage> Process>>evaluate: <aMessage>
|
|
konijn
Junior Member
Posts: 96
|
Post by konijn on Jun 20, 2022 15:41:09 GMT -5
I got it working. I missed the ftp dll file.
|
|