Announcement

Collapse
No announcement yet.

Simple Email DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple Email DLL

    I am looking for a simple email program preferably a DLL.

    I would like be able to send an RTF file as an email. I would like to do this programmatically. I am hoping someone may know of an email DLL or program preferably written in PowerBasic.

  • #2
    how about BLAT

    While I have never interfaced to BLAT via it's DLL I have used it though the shell in several projects.

    http://www.blat.net/
    BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

    Comment


    • #3
      While I have never interfaced to BLAT via it's DLL I have used it though the shell in several projects.
      Ditto. If I'd have known there were a DLL-based API I think I woudl have used it, since creating the "command file" for use with shell-operation was kind of a PITA.

      There are also several code examples here of using both SMTP and MAPI to send email, with and without attachments.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Frank,
        Thank you. I think that is what I need. Looks like the DLL and EXE versions use the same syntax.
        But the syntax documentation is a bit comfusing for me. Would you be able to help me out?

        What would be the command line syntax if I want to email a file?
        Here are the particulars:

        file= Test.txt

        To= [email protected]

        From= [email protected]

        smtp= mail.server.com

        username= myname

        password= mypassword

        How would the command line argument be structure?

        Comment


        • #5
          >But the syntax documentation is a bit comfusing for me

          The syntax for blat? Yes, it is.

          There's also restrictions on long/short filenames, rules for filenames with spaces in them, etc. etc.

          As long as you are in control here, just adapt one or more of the SMTP or MAPI examples here and leave the third-party program out. (But don't try MAPI if using Exchange Server, I never got that to work).

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Micheal,
            Thanks for the suggestion. I did a search for SMTP and found two programs one was an CC program, which would compile and when run give me as dos box. Unfortunately, no document as to what to do with it at that point.
            The other would not compile but appears to be for PB8 or Pb9.

            Did you have some thing in mind? Can you post a link?

            If I could figure out the syntax , I think BLAT.DLL would be a better way to go.

            Comment


            • #7
              I have code to email the file via Exchange, email if interested - have to dig it out of the archives...
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


              • #8
                Do two searches here for "message subject," forum "Source code," all dates.

                Do one on keyword "email" and another on keyword "e-mail"

                There's over twenty "hits" between the two keywords.

                There has GOT to be something you can use without screwing around learning the API for a third-party product.
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Originally posted by Martin Francom View Post
                  I am looking for a simple email program preferably a DLL.

                  I would like be able to send an RTF file as an email. I would like to do this programmatically. I am hoping someone may know of an email DLL or program preferably written in PowerBasic.
                  http://www.greatwebdivide.com/software_ddsmtp.htm

                  available from Don Dickinson.

                  Comment


                  • #10
                    example

                    this is how i have been using it, with you example added

                    Code:
                    blat Test.txt -attach "Test.txt" -to [email protected] -f [email protected] -server mail.server.com -u myname -pw mypassword -body "nightly system updates" -subject "nightly export server [e12-stu-001]"
                    file= Test.txt

                    To= [email protected]

                    From= [email protected]

                    smtp= mail.server.com

                    username= myname

                    password= mypassword

                    I hope this helps
                    BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

                    Comment


                    • #11
                      Hi Marty,

                      I am pretty sure that the PB Class that I posted for you back in March (on PlanetSquires) could handle plain and html messages as well as do server authentication. It does the basics and is all PB code but I imagine that BLAT is much more comprehensive.
                      Paul Squires
                      FireFly Visual Designer (for PowerBASIC Windows 10+)
                      Version 3 now available.
                      http://www.planetsquires.com

                      Comment


                      • #12
                        Frank,
                        Thank you! thank you!

                        Once you know how to string the syntax together it works like a charm!

                        I assume the DLL version uses simular syntax. I will give it a try.

                        Note to others: The syntax suggested by Frank works with BLAT version 2.62 I tried it with some earlier versions and ran into some problems.

                        Comment


                        • #13
                          Ostrosoft SMTP
                          At 192K - the dll is not too huge. I've used it for years in my VB6 apps. Haven't tried it yet with my PowerBASCI stuff.

                          http://www.ostrosoft.com/smtp_component.asp

                          I went to the site today and saw a .NET version. Couldn't find the link for the COM DLL but would guess it's still around.

                          Comment


                          • #14
                            Here my RemailPlus DLL (pure PowerBasic):
                            http://www.direct-print.com/RemailPlusdll.htm

                            Peter Redei

                            Comment


                            • #15
                              Here's a quicky PBCC program to demonstrate how to use BLAT
                              You can get the BLAT EXE and/or DLL at: http://www.blat.net/

                              Code:
                              #COMPILE EXE
                              #DIM ALL
                              
                              
                              DECLARE FUNCTION SendBlat LIB "blat.dll" ALIAS "Send" (BYVAL sCmd AS STRING) AS INTEGER
                              
                              
                              FUNCTION PBMAIN () AS LONG
                                 
                                 
                               
                                 DIM sCmd AS STRING
                                 DIM rc%
                                 
                                 DIM ToAdd AS STRING
                              
                                 DIM FromAdd AS STRING
                                 DIM ServerAdd AS STRING
                                 DIM BodyF AS STRING
                                 DIM Subject AS STRING
                                 DIM Uname AS STRING
                                 DIM Pword AS STRING
                                 DIM aFile AS STRING
                                 
                                 ToAdd = "[email protected]"           'correct variables to be consistant with your needs
                                 FromAdd = "[email protected]"
                                 ServerAdd = "smtp.gmail.com"
                                 Subject = "What ever it is"
                                 BodyF = "TestInfo.txt"    'or "TestInfo.htm"
                                    'otionally you can use   Body = "string of info"
                                 Uname = "UserName"
                                 Pword = "password"
                                 aFile = "a file to attach such as Test.pdf"
                                   
                                   
                                 sCmd = ""
                                 IF LEN(aFile) > 0 THEN
                                   sCmd = aFile + " -attach " + CHR$(34) + aFile + CHR$(34, 32)
                                 END IF
                                 sCmd = sCmd + "-to " + ToAdd " + " -f " + FromAdd
                                 sCmd = sCmd + " -server " + ServerAdd + " -u " + Uname + " -pw " + Pword
                                 sCmd = sCmd + " -bodyF "+ CHR$(34) + BodyF +CHR$(34)
                                 sCmd = sCmd + " -subject " + CHR$(34) + Subject +CHR$(34)
                               
                                 'rc% = SendBlat (Byval sCmd)
                                 SHELL "Blat " + sCmd
                               
                                 WAITKEY$
                              
                              END FUNCTION

                              Comment


                              • #16
                                Is there a way to test to see if the email failed to send and at what point the fail happened?

                                I noticed that the DLL version is based on a pretty old version of BLAT.
                                Paul Squires
                                FireFly Visual Designer (for PowerBASIC Windows 10+)
                                Version 3 now available.
                                http://www.planetsquires.com

                                Comment


                                • #17
                                  I wrote a web application that has been hit about 50 times a day, 5 days a week, for the last ten+ years.

                                  It shells out to Blat.exe

                                  That's my endorsement
                                  https://www.BcxBasicCoders.com
                                  BCX BASIC to C/C++ for Windows

                                  Comment


                                  • #18
                                    Originally posted by Paul Squires View Post
                                    Is there a way to test to see if the email failed to send and at what point the fail happened?

                                    I noticed that the DLL version is based on a pretty old version of BLAT.
                                    Paul,
                                    The DLL I got from the BLAT web site is 2.62 What newer version are you talking about?
                                    Yes, you do get a message back from BLAT.DLL to tell you about success or failure. I modified the earlier code to include the return code.
                                    Hope that helps.

                                    Code:
                                    #COMPILE EXE
                                    #DIM ALL
                                    
                                    
                                    DECLARE FUNCTION SendBlat LIB "blat.dll" ALIAS "Send" (BYVAL sCmd AS STRING) AS LONG
                                    
                                    
                                    FUNCTION PBMAIN () AS LONG
                                    
                                    
                                    
                                       DIM sCmd AS STRING
                                       DIM rc&
                                       DIM msg AS STRING
                                    
                                       DIM ToAdd AS STRING
                                    
                                       DIM FromAdd AS STRING
                                       DIM ServerAdd AS STRING
                                       DIM BodyF AS STRING
                                       DIM Subject AS STRING
                                       DIM Uname AS STRING
                                       DIM Pword AS STRING
                                       DIM aFile AS STRING
                                    
                                    
                                       ToAdd = "[email protected]"
                                       FromAdd = "[email protected]"
                                       ServerAdd = "smtp.comcast.net"
                                       Subject = "Testing BLAT eMail Sender"
                                       BodyF = "RxRefill.htm"    'or "TestInfo.txt"
                                          'otionally you can use   Body = "string of info"
                                       Uname = "SpecialMeds"
                                       Pword = "Medshop2541"
                                       aFile = ""    '  "Test.pdf"
                                    
                                    
                                       sCmd = ""
                                       IF LEN(aFile) > 0 THEN
                                         sCmd = aFile + " -attach " + CHR$(34) + aFile + CHR$(34, 32)
                                       END IF
                                       sCmd = sCmd + "-to " + ToAdd  + " -f " + FromAdd
                                       sCmd = sCmd + " -server " + ServerAdd + " -u " + Uname + " -pw " + Pword
                                       sCmd = sCmd + " -bodyF "+ CHR$(34) + BodyF +CHR$(34)
                                       sCmd = sCmd + " -subject " + CHR$(34) + Subject +CHR$(34)
                                    
                                       rc& = SendBlat (BYVAL sCmd)
                                       'SHELL "Blat " + sCmd
                                       GOSUB eCodes
                                       PRINT rc&, msg$
                                       WAITKEY$
                                    EXIT FUNCTION
                                    
                                    eCodes:
                                      SELECT CASE rc&
                                          CASE 0 : msg$ = "No Errors - Successful Transmission"
                                          CASE 1 : msg$ = "Bad File Name or Argument"
                                          CASE 2 : msg$ = "File or Massage txt does not exists
                                          CASE 3 : msg$ = "Error reading file - BodyFile or Attached File"
                                          CASE 4 : msg$ = "File (message text) not of type FILE_TYPE_DISK"
                                          CASE 5 : msg$ = "Error Reading File (message text)"
                                          CASE 12: msg$ = "-server or -f options not specified and not found in registry"
                                          CASE 13: msg$ = "Error opening temporary file in temp directory"
                                          CASE 4001: msg$ = "Error: Malloc failed (possibly out of memory)."
                                          CASE 4002: msg$ = "Error: Error sending data."
                                          CASE 4003: msg$ = "Error: Error initializing gensock.dll."
                                          CASE 4004: msg$ = "Error: Version not supported."
                                          CASE 4005: msg$ = "Error: The winsock version specified by gensock is not supported by this winsock.dll."
                                          CASE 4006: msg$ = "Error: Network not ready."
                                          CASE 4007: msg$ = "Error: Can't resolve (mailserver) hostname."
                                          CASE 4008: msg$ = "Error: Can't create a socket (too many simultaneous links?)"
                                          CASE 4009: msg$ = "Error: Error reading socket."
                                          CASE 4010: msg$ = "Error: Not a socket."
                                          CASE 4011: msg$ = "Error: Busy."
                                          CASE 4012: msg$ = "Error: Error closing socket."
                                          CASE 4013: msg$ = "Error: Wait a bit (possible timeout)."
                                          CASE 4014: msg$ = "Error: Can't resolve service."
                                          CASE 4015: msg$ = "Error: Can't connect to mailserver (timed out if winsock.dll error 10060)"
                                          CASE 4016: msg$ = "Error: Connection to mailserver was dropped."
                                          CASE 4017: msg$ = "Error: Mail server refused connection."
                                       END SELECT
                                     RETURN
                                    
                                    
                                    END FUNCTION

                                    Comment


                                    • #19
                                      Originally posted by Martin Francom View Post
                                      assume the DLL version uses simular syntax. I will give it a try.
                                      The only thing to be careful of with the DLL is that, unlike the Exe, extra spaces will cause problems. You must make sure that there is exactly one space before and after each switch.

                                      Comment


                                      • #20
                                        >You must make sure that there is exactly one space before and after each switch.

                                        Work saver?
                                        Code:
                                        $COMMAND_MASK = "-a & -to & -from &" 
                                        
                                        ...
                                            Param$ = USING$ ($COMMAND_MASK, OptionA$, TO$, From$)
                                        Pretty easy to see and fix up spacing, or to add/subtract command-line options if what you first choose is not what you want. Get the spacing correct in $COMMAND_MASK ONCE and the rest of the job is a lot easier to code.

                                        MCM
                                        Michael Mattias
                                        Tal Systems (retired)
                                        Port Washington WI USA
                                        [email protected]
                                        http://www.talsystems.com

                                        Comment

                                        Working...
                                        X