Skip to content

Sending Email from within Simpol

Forums Forums SIMPOL Programming Sending Email from within Simpol

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #259
    Jean Vallee
    Participant

    I am using Shellexecute to call the user’s default email program and insert the usual.. to subject etc. The msg I want to send is too long for the shellexecute parameter so I just want to copy the text to the clipboard and paste into the email. The problem is:I have no idea what email program shellexecute will call. Once I know I can use appactivate and paste. I know the default email client program name is store in the registry under HKLMSOFTWAREClientsMail in the (Default) key. Anyone have any code snippets for win32_registry to read the value of a key in the registry? Jean Vallee

    #2269
    Michael
    Keymaster

    On 26/06/2013 19:41, JV wrote:
    > I am using Shellexecute to call the user's default email program and
    > insert the usual.. to subject etc.
    > The msg I want to send is too long for the shellexecute parameter so I
    > just want to copy the text to the clipboard and paste into the email.
    > The problem is:I have no idea what email program shellexecute will call.
    > Once I know I can use appactivate and paste.
    > I know the default email client program name is store in the registry
    > under HKLMSOFTWAREClientsMail in the (Default) key.
    > Anyone have any code snippets for win32_registry to read the value of a
    > key in the registry?
    >
    > Jean Vallee
    >

    There is a registry library in the distribution. You basically have to open it, then read a value, then close it if I remember
    correctly.

    Ciao, Neil

    #2270
    Jean Vallee
    Participant

    On 6/26/2013 2:41 PM, JV wrote:
    > I am using Shellexecute to call the user's default email program and
    > insert the usual.. to subject etc.
    > The msg I want to send is too long for the shellexecute parameter so I
    > just want to copy the text to the clipboard and paste into the email.
    > The problem is:I have no idea what email program shellexecute will call.
    > Once I know I can use appactivate and paste.
    > I know the default email client program name is store in the registry
    > under HKLMSOFTWAREClientsMail in the (Default) key.
    > Anyone have any code snippets for win32_registry to read the value of a
    > key in the registry?
    >
    > Jean Vallee
    I gave up trying to find out…
    What I ended up doing was calling shellexecute with open and
    constructing a string as the second parameter:

    "mailto:" + cr!CntrDFon+ "?subject=" +"Address:%20" +
    me!jobaddr.control.text + "%20Permit%20#:%20" + me!inspptno.control.text
    + " Insp%20#:%20"+me!inspnum.control.text

    Any spaces must be sent as urlencode characters (%20 = space)

    The shellexecute make the mail program the active app and put the cursor
    into the body, so I copied the text I wanted from the record to the
    clipboard and pasted.
    Then it's up to the user to make any changes they want and send.

    #2271
    JD Kromkowski
    Participant

    I've been able to do this using mailto and Shellexecute too.

    But I'd really like to use sendmail() See Chapter 68. sendmail

    sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    sMessage, string sMailhost, string sHostname, string sTimezone, string
    sReplyto, string authtype, string username, string password, boolean
    usehtml, array attachments )

    My problem is a really don't understand the parameters.

    what exactly goes in sMailhost and sHostname, authtype, username, etc.

    On 06/29/13 9:02 PM, JV wrote:
    > On 6/26/2013 2:41 PM, JV wrote:
    >> I am using Shellexecute to call the user's default email program and
    >> insert the usual.. to subject etc.
    >> The msg I want to send is too long for the shellexecute parameter so I
    >> just want to copy the text to the clipboard and paste into the email.
    >> The problem is:I have no idea what email program shellexecute will call.
    >> Once I know I can use appactivate and paste.
    >> I know the default email client program name is store in the registry
    >> under HKLMSOFTWAREClientsMail in the (Default) key.
    >> Anyone have any code snippets for win32_registry to read the value of a
    >> key in the registry?
    >>
    >> Jean Vallee
    > I gave up trying to find out…
    > What I ended up doing was calling shellexecute with open and
    > constructing a string as the second parameter:
    >
    > "mailto:" + cr!CntrDFon+ "?subject=" +"Address:%20" +
    > me!jobaddr.control.text + "%20Permit%20#:%20" + me!inspptno.control.text
    > + " Insp%20#:%20"+me!inspnum.control.text
    >
    > Any spaces must be sent as urlencode characters (%20 = space)
    >
    > The shellexecute make the mail program the active app and put the cursor
    > into the body, so I copied the text I wanted from the record to the
    > clipboard and pasted.
    > Then it's up to the user to make any changes they want and send.

    #2272
    Michael
    Keymaster

    On 15/07/2013 15:57, kromkowski wrote:
    > I've been able to do this using mailto and Shellexecute too.
    >
    > But I'd really like to use sendmail() See Chapter 68. sendmail
    >
    > sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    > sMessage, string sMailhost, string sHostname, string sTimezone, string
    > sReplyto, string authtype, string username, string password, boolean
    > usehtml, array attachments )
    >
    > My problem is a really don't understand the parameters.
    >
    > what exactly goes in sMailhost and sHostname, authtype, username, etc.

    sMailhost = the smtp server that you are sending to
    sHostname = the machine sending it (this is best if it can be resolved, to avoid being immediately classed as SPAM). See DYNDNS to
    get a hostname for a machine at a dynamic IP address.
    sTimezone and sReplyTo are optional
    authtype is either 1 for AUTH_PLAIN or 2 for AUTH_LOGIN. The first sends the password in plain text, the second encrypts it slightly.
    username and password are the login credentials for that user to send email through the smtp provider named in sMailhost. If you
    do not need any credentials, then you don't need these items.
    usehtml activates the sMIME mode for HTML content. However, it does not make a text version of the HTML email currently, and
    sending purely HTML emails will get an increased SPAM score, so your mileage may vary with it.
    attachments is just an array of file names that should be sent. Obviously size can become an issue here.

    Ciao, Neil

    #2273
    Michael
    Keymaster

    On 16/07/2013 17:52, Neil Robinson wrote:
    > On 15/07/2013 15:57, kromkowski wrote:
    >> I've been able to do this using mailto and Shellexecute too.
    >>
    >> But I'd really like to use sendmail() See Chapter 68. sendmail
    >>
    >> sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    >> sMessage, string sMailhost, string sHostname, string sTimezone, string
    >> sReplyto, string authtype, string username, string password, boolean
    >> usehtml, array attachments )
    >>
    >> My problem is a really don't understand the parameters.
    >>
    >> what exactly goes in sMailhost and sHostname, authtype, username, etc.
    >
    > sMailhost = the smtp server that you are sending to
    > sHostname = the machine sending it (this is best if it can be resolved, to avoid being immediately classed as SPAM). See DYNDNS to
    > get a hostname for a machine at a dynamic IP address.

    A friend of mine pointed out, this actually needs to be the name that your external IP address resolves to, which is typically
    something like: "a-b-c-d.dyn.example.net". The bigger problem when doing this sort of thing is you need to make sure that you are
    not falling foul of the anti-spam filters, so a lot of preliminary testing is required, preferably sent to an account where you
    can control what happens to the spam, and where if possible you can see the spam headers that get added to the email to adjust
    your content.

    Ciao, Neil

    #2275
    JD Kromkowski
    Participant

    On 07/17/13 7:08 AM, Neil Robinson wrote:
    > On 16/07/2013 17:52, Neil Robinson wrote:
    >> On 15/07/2013 15:57, kromkowski wrote:
    >>> I've been able to do this using mailto and Shellexecute too.
    >>>
    >>> But I'd really like to use sendmail() See Chapter 68. sendmail
    >>>
    >>> sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    >>> sMessage, string sMailhost, string sHostname, string sTimezone, string
    >>> sReplyto, string authtype, string username, string password, boolean
    >>> usehtml, array attachments )
    >>>
    >>> My problem is a really don't understand the parameters.
    >>>
    >>> what exactly goes in sMailhost and sHostname, authtype, username, etc.
    >>
    >> sMailhost = the smtp server that you are sending to
    >> sHostname = the machine sending it (this is best if it can be resolved, to avoid being immediately classed as SPAM). See DYNDNS to
    >> get a hostname for a machine at a dynamic IP address.
    >
    > A friend of mine pointed out, this actually needs to be the name that your external IP address resolves to, which is typically
    > something like: "a-b-c-d.dyn.example.net". The bigger problem when doing this sort of thing is you need to make sure that you are
    > not falling foul of the anti-spam filters, so a lot of preliminary testing is required, preferably sent to an account where you
    > can control what happens to the spam, and where if possible you can see the spam headers that get added to the email to adjust
    > your content.
    >
    > Ciao, Neil

    I'm not sure I totally understood this in the first place.

    sMailhost – I understood (or so I imagined it to be "smtp.gmail.com")

    sHostname – This has been problematic for me to understand – can't I
    just get this from "what is my ip address" or do I need something else?
    IPv4 or IPv6

    But the sendmail function doesn't seem to require SMTP port or SMTP
    TLS/SSL as parameters? E.g.

    Gmail SMTP server address: smtp.gmail.com
    Gmail SMTP user name: Your full Gmail address (e.g. exa****@**ail.com)
    Gmail SMTP password: Your Gmail password
    Gmail SMTP port: 465
    Gmail SMTP TLS/SSL required: yes

    JDK

    #2274
    JD Kromkowski
    Participant

    On 07/16/13 12:52 PM, Neil Robinson wrote:
    > sTimezone and sReplyTo are optional

    I don't think sTimezone is optional. I finally included the
    sendmail.sma so I could debug and without sTimezone it falls down:

    else if sTimezone <= ""
    retval = "Error: no time zone"
    else if not validtimezone(sTimezone)
    retval = "Error: invalid time zone: " + sTimezone

    But I have no idea what the proper format is for sTimezone

    "EST"

    Or

    "-500"

    ?

    Having looked at some other code I am also think that the serverhost

    maybe should be in format "xxx.xxx.xxx.xxx:port"

    where xxx etc is IP
    where port is (see other post for example with gmail)

    Maybe?

    #2276
    Michael
    Keymaster

    On 17/07/2013 17:47, kromkowski wrote:
    > On 07/17/13 7:08 AM, Neil Robinson wrote:
    >> On 16/07/2013 17:52, Neil Robinson wrote:
    >>> On 15/07/2013 15:57, kromkowski wrote:
    >>>> I've been able to do this using mailto and Shellexecute too.
    >>>>
    >>>> But I'd really like to use sendmail() See Chapter 68. sendmail
    >>>>
    >>>> sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    >>>> sMessage, string sMailhost, string sHostname, string sTimezone, string
    >>>> sReplyto, string authtype, string username, string password, boolean
    >>>> usehtml, array attachments )
    >>>>
    >>>> My problem is a really don't understand the parameters.
    >>>>
    >>>> what exactly goes in sMailhost and sHostname, authtype, username, etc.
    >>>
    >>> sMailhost = the smtp server that you are sending to
    >>> sHostname = the machine sending it (this is best if it can be resolved, to avoid being immediately classed as SPAM). See DYNDNS to
    >>> get a hostname for a machine at a dynamic IP address.
    >>
    >> A friend of mine pointed out, this actually needs to be the name that your external IP address resolves to, which is typically
    >> something like: "a-b-c-d.dyn.example.net". The bigger problem when doing this sort of thing is you need to make sure that you are
    >> not falling foul of the anti-spam filters, so a lot of preliminary testing is required, preferably sent to an account where you
    >> can control what happens to the spam, and where if possible you can see the spam headers that get added to the email to adjust
    >> your content.
    >>
    >> Ciao, Neil
    >
    > I'm not sure I totally understood this in the first place.
    >
    > sMailhost – I understood (or so I imagined it to be "smtp.gmail.com")
    >
    > sHostname – This has been problematic for me to understand – can't I
    > just get this from "what is my ip address" or do I need something else?
    > IPv4 or IPv6
    >
    > But the sendmail function doesn't seem to require SMTP port or SMTP
    > TLS/SSL as parameters? E.g.
    >
    > Gmail SMTP server address: smtp.gmail.com
    > Gmail SMTP user name: Your full Gmail address (e.g. exa****@**ail.com)
    > Gmail SMTP password: Your Gmail password
    > Gmail SMTP port: 465
    > Gmail SMTP TLS/SSL required: yes

    Sending through Gmail is a special problem, because they want the data to be encrypted using SSL, which we don't currently supply.
    I have successfully sent mail through Gmail by using the stunnel program to create an SSL tunnel that forwards the SMTP traffic to
    Gmail.

    To set the port, in the sMailhost you simply add :465, but that won't work here. Instead, you configure stunnel correctly to
    forward to Gmail, and then you connect to localhost:25 to send the email.

    Ciao, Neil

    #2281
    JD Kromkowski
    Participant

    Pretty complicated. If I want to use gmail.

    I'm just looking at comcast which (as of this week apparantly) no longer
    supports the use of port 25 for sending email.

    And they recommend SSL although as of yet do not require it.

    JDK

    On 07/18/13 7:15 AM, Neil Robinson wrote:
    > On 17/07/2013 17:47, kromkowski wrote:
    >> On 07/17/13 7:08 AM, Neil Robinson wrote:
    >>> On 16/07/2013 17:52, Neil Robinson wrote:
    >>>> On 15/07/2013 15:57, kromkowski wrote:
    >>>>> I've been able to do this using mailto and Shellexecute too.
    >>>>>
    >>>>> But I'd really like to use sendmail() See Chapter 68. sendmail
    >>>>>
    >>>>> sendmail ( string sFrom, string sEmailaddr, string sSubject, string
    >>>>> sMessage, string sMailhost, string sHostname, string sTimezone, string
    >>>>> sReplyto, string authtype, string username, string password, boolean
    >>>>> usehtml, array attachments )
    >>>>>
    >>>>> My problem is a really don't understand the parameters.
    >>>>>
    >>>>> what exactly goes in sMailhost and sHostname, authtype, username, etc.
    >>>>
    >>>> sMailhost = the smtp server that you are sending to
    >>>> sHostname = the machine sending it (this is best if it can be resolved, to avoid being immediately classed as SPAM). See DYNDNS to
    >>>> get a hostname for a machine at a dynamic IP address.
    >>>
    >>> A friend of mine pointed out, this actually needs to be the name that your external IP address resolves to, which is typically
    >>> something like: "a-b-c-d.dyn.example.net". The bigger problem when doing this sort of thing is you need to make sure that you are
    >>> not falling foul of the anti-spam filters, so a lot of preliminary testing is required, preferably sent to an account where you
    >>> can control what happens to the spam, and where if possible you can see the spam headers that get added to the email to adjust
    >>> your content.
    >>>
    >>> Ciao, Neil
    >>
    >> I'm not sure I totally understood this in the first place.
    >>
    >> sMailhost – I understood (or so I imagined it to be "smtp.gmail.com")
    >>
    >> sHostname – This has been problematic for me to understand – can't I
    >> just get this from "what is my ip address" or do I need something else?
    >> IPv4 or IPv6
    >>
    >> But the sendmail function doesn't seem to require SMTP port or SMTP
    >> TLS/SSL as parameters? E.g.
    >>
    >> Gmail SMTP server address: smtp.gmail.com
    >> Gmail SMTP user name: Your full Gmail address (e.g. exa****@**ail.com)
    >> Gmail SMTP password: Your Gmail password
    >> Gmail SMTP port: 465
    >> Gmail SMTP TLS/SSL required: yes
    >
    > Sending through Gmail is a special problem, because they want the data to be encrypted using SSL, which we don't currently supply.
    > I have successfully sent mail through Gmail by using the stunnel program to create an SSL tunnel that forwards the SMTP traffic to
    > Gmail.
    >
    > To set the port, in the sMailhost you simply add :465, but that won't work here. Instead, you configure stunnel correctly to
    > forward to Gmail, and then you connect to localhost:25 to send the email.
    >
    > Ciao, Neil
    >

    #3455
    Tim Gordon
    Participant

    I am having difficulty with sendmail().
    I see now that this is to a great extent because gmail demands SSL format.
    Are there any plans to add this capability to Simpol?

    Because I am calling Simpol from Classic Superbase I need to create the OutputFile but I do not understand the syntax for this.

    #3456
    Michael
    Keymaster

    You can download and configure stunnel https://www.stunnel.org/downloads.html and then instead of sending to your smtp host directly, you send it to localhost:25 for example. There are pre-built configuration entries for gmail smtp, pop3, and imap.

    As for the syntax, do you mean you don’t know how to create the output file in Superbase Classic?

    #3457
    Tim Gordon
    Participant

    I put a question mark in front of, and quotation marks around every line.
    Each line corresponds to a parameter for sendmail() up to and including “HasAttachments”.
    Is this meant to create a text file in the “temp” folder? (It didn’t).

    [System]
    From=tim@abetterway.com
    To=joe@gmail.com
    Subject=Test
    Message=Hi Joe,{a}{a}This is just a test test test.{a}{a}Regards, Tim
    # // The following is your smtp server
    MailHost=smtp.gmail.com
    HostName=tgabetterway@gmail.com
    TimeZone=-0800 (PST)
    ReplyTo= tgabet******@**ail.com
    AuthType=2
    UserName=servicecall
    Password=dk220212
    UseHtml=0
    HasAttachments=0
    OutputFile=c:\temp\sbm132d8.txt

    [Attachments]
    1=c:\SIMPOL\docs\license.txt

    #3458
    Michael
    Keymaster

    The OutputFile= parameter is for you to fill out as desired. You may not even have a c:\temp folder. Just choose where you want the output to go (valid path name on your machine).

    Once you have the parameter file built, you pass it to the sendmail program and it will output its results in the Outfile= file.

    Ciao, Neil

    #3459
    Tim Gordon
    Participant

    I do have a c:\temp folder, but a txt file does not get written in it.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.