Results 1 to 4 of 4

Thread: Simple SMTP_SSL with console mailsend

  1. #1
    Junior Member M30_NXG's Avatar
    Join Date
    Oct 2018
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Post Simple SMTP_SSL with console mailsend

    Hello,
    to all.

    My first posting is a short console solution, inspired from a
    existing VB-script.
    Realized with an minimalistic code skeleton for proofing
    and demonstrating the idea.

    The simple recipe: iDispatch is used. ;-)
    So the VBS code needs only smooth changes to work within Thinair. ;-)

    - What we do:
    We send a mail message via console without using Thunderbird, Outlook,
    etc. mail clients
    To realize this i use mailsend, a free console textbased mail client.


    Necessary steps..

    1.)
    look at:
    https://github.com/muquit/mailsend/releases/
    https://github.com/muquit/mailsend/#features

    2.)
    Download mailsend v1.19 - Latest stable version
    mailsend1.19.exe.zip - zipped windows binary.

    UNZIP it in drive:Dir\path of your choice.
    If you wish, rename it to MS.EXE (no must, but it's handy)

    3.)
    Adjust the variables for SMTP-Mail and the above (2.))
    Drive:Dir\path combination to your situation.
    See the comments in the source file.

    4.)
    Feel free to modify and use
    Thinair - hit F5 - should do the rest

    Stumbeling...
    In Line 83 i have a litte problem with the OS_Shell command.
    The Body is cutted after about 240-250 chars length.
    The "pure VBS solution" , see line 86 seems to work.
    Any idea ?

    Thanks

    Ben


    ' SimpleSMTP_SSL 
    '-----------------------
    '  based on an existing VB-Script solution
    
    '-- Prepare :
    ' (1.) Download mailsendxxx from :
    ' https://github.com/muquit/mailsend/releases/
    ' https://github.com/muquit/mailsend/#features
    
    ' to an Dir\Path of your choice. Manually rename it to MS.EXE
    ' Short name is better to handle, but no must.
    '=============================================================
    Uses "Console"
    Uses "OS"
    '-----------Change here for your suits ---------
    ' eventual look at your Mail- Client settings to get the right settings
    ' (2.) User / Provider data... / SMTP Server 
    '-----------------------------------------------
    Dim Msender     As String ="XXXXX@YZ.de"    'SenderName  -- sender@xyz.de
    Dim Mserver     As string ="SMTPxxxx.de"    'SMTP Server -- smtpserver.it
    Dim Mpass       As string ="##########"     'Passwort    -- your Mail PWD
    Dim Mreceiver   As String ="RRRRR@Mail.de"  'receiver    -- to 
    Dim sSLLPort    as string = "465"           ' SSL Port.. -- SSL port
    '-----------------------------------------------
    '-- Change here  the location of mailsend.exe ************
    Dim MSendeApp As String  ="c:\skripte\ms.exe"  'MS.EXE is here at home <--
    
    
    String  sAPP_Version   =  """ TB Simple SMTP SSL Tester - send by PC : """
    '--------- MAIN ---------------
    Function TBMain() As Long
    Call Mail_send
          PrintL "**__END__ "  & crLF & "( Hit Key to Exit )**"
    WaitKey 
    End Function
    ' ----- END MAIN ---------------
    
    '------------------------------------------
    Sub Mail_send() 'poor man solution ;-)
    '------------------------------------------
       ''** WARNIG. MS.EXE is sensible on missing or wrong double quotes or spaces
       ''** between the parameters. Symptom : No mail is sended
       Dim  oMsg  as  idispatch
       Dim  SendMail_Wrapper   as String 
       Dim TestBody  as String
       '-- here you can chain your Body text
       TestBody ="1111111110" & $LF & _
                 "2222222220" & $LF & _
                 "3333333330" & $LF & _
                 "4444444440" & $LF & _
                 "5555555550" & $LF & _
                 "6666666660" & $LF & _
                 "7777777770" & $LF & _
                 "9999999990" & $LF & _
                 "AAAAAAAAA0" & $LF & _
                 "BBBBBBBBB0" & $LF & _
                 "CCCCCCCCC0" & $LF & _
                 "DDDDDDDDD0"
      '--magic ---IdisPatch--sorry no CHK -> on if IsComObject <-in this sample-          
       oMsg = Newcom("WScript.Shell")
      
       '-- simple wrapper for MS.EXE arguments
       ' (- v Option) ist active for dbg ;-)
       '------------------------------------------------
       SendMail_Wrapper = " -f " &  Mreceiver    & _
                 " -t " &  Mreceiver & _ 
                 " -ssl -port " & sSLLPort & " -auth -smtp " & Mserver & _ 
                 " -user " & Msender   & _
                 " -pass " & Mpass   & _
                 " -sub " &  sAPP_Version &   OS_GetComputerName  &  _
                 " -v "  &  " -M " & " "  & _
                 TestBody 
                 '-- feel free to add more Body- text
        '--------------------------------------------------------
        
    'litte dbg, because of problem  with OS_Shell '   
    PrintL  "**dbg_Info Send-Packet **:" , SendMail_Wrapper 
    PrintL  "**dbg_Info Length        :" , Len(SendMail_Wrapper) & crLf
    
    '?? Here i am struggeling with the native OS_Shell command 
    ' --- only ca. 240 - 250 Chars are transported , then cut ? why ? mh, mh?
    ' Perhaps  MS.EXE ? 
    'OS_Shell(MSendeApp & " " &  SendMail_Wrapper , %OS_WNDSTYLE_MAXIMIZED, %OS_SHELL_SYNC)
    
    '--- no problem with Len in this solution (SendMail_Wrapper) 
    oMsg.run (MSendeApp & " " & SendMail_Wrapper, 0, True)
       
    oMsg = Nothing
    
    End Sub
    ''//EOF
    
    Attached Files Attached Files

  2. #2
    Hi, M30_NXG

    Quote Originally Posted by M30_NXG View Post
    '?? Here i am struggeling with the native OS_Shell command 
    ' --- only ca. 240 - 250 Chars are transported , then cut ? why ? mh, mh?
    ' Perhaps  MS.EXE ? 
    'OS_Shell(MSendeApp & " " &  SendMail_Wrapper , %OS_WNDSTYLE_MAXIMIZED, %OS_SHELL_SYNC)
    
    just an idea (I'm a newcomer at ThinBasic) : have you try with OS_ShellExecute ?

    hInstance = OS_ShellExecute(Open, MSendeApp , SendMail_Wrapper, "c:\skripte\",%SW_SHOWMAXIMIZED)
    
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    55
    Posts
    8,661
    Blog Entries
    2
    Rep Power
    10
    Hi Ben,

    thanks a lot for this great entrance in thinBasic.

    I didn't know about MailSend, it can be very useful.
    thinBasic has a SMTP module but MailSend support ESMPT and IPV6
    Very compact, I will study it.

    And yes, thinBasic has OS_Shell functions but the use of iDispatch is great.
    I like the idea to use all the tools that are available and find different ways to do the same things.

    I will check OS_Shell limitations, maybe I can improve command line max number of chars

    Ciao
    Eros
    Last edited by ErosOlmi; 01-11-2018 at 20:20.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    55
    Posts
    8,661
    Blog Entries
    2
    Rep Power
    10
    I've developed a new Shell function without command line limitations.
    It will be a new keyword directly in Core engine of thinBasic so no need to load OS module to use it.
    Will be present in next release.

    Ben, thanks for spotting it
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Simple DNA Model
    By rjp74 in forum TBGL Scripts and Projects
    Replies: 7
    Last Post: 21-09-2012, 12:44
  2. Prompt > Simple console demo of word whisperer
    By Petr Schreiber in forum Console: source code examples for beginners
    Replies: 4
    Last Post: 11-07-2012, 21:59
  3. Console Box and Console Readline
    By TheOne in forum Console
    Replies: 8
    Last Post: 22-03-2011, 18:32
  4. My simple editor
    By Aurel in forum Alternative IDEs
    Replies: 38
    Last Post: 10-01-2011, 19:51
  5. Simple MCI utility
    By Petr Schreiber in forum Win API interface
    Replies: 2
    Last Post: 24-05-2006, 21:06

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •