Alpha DevCon 2018
Results 1 to 24 of 24

Thread: Email_Send() Help

  1. #1
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default Email_Send() Help

    I'm trying to alert myself via email whenever someone submits data to one of my online forms, and I'm having a tough time with the expression. All I need is the email handler to send email to "BHPD104@aol.com," with the message "Form Has Data On It." No attachments, No Zip Files, nothing but a message letting me know that the "submit" button has been pushed. I have already setup my default email profile and tested it, and it works fine.

    I'm putting the following code in the AfterUpdateRecords section:

    EMAIL_SEND( [ BHPD104@aol.com [, Form Has Data On It [, Message as C [, Attachments as C [, CC as C [, BCC as C [, Store_In_Outbox as L [, Text_Type as C [, HTML_Message as C [, default [, Zip_Attach as L [, Silent as L ]]]]]]]]]] )

    I'm not sure what to put in the "Carbon Copy, Blind Carbon Copy, etc." places, since I'm not using any of these options. As a result, I am getting the following error message when attempting to save the updated form:

    Error: Syntax error in event 'AfterUpdateRecords' Error at line: 1, column: 1 Error: Expected value<body

    If someone could correct my expression I would appreciate it.

  2. #2
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default

    Since the BCC field is character, you would insert "". Try the EMAIL_SEND2() function. It is easier to use.

  3. #3
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default

    I hope it is clear that an argument with brackets [] is optional. However, if you want to use any optional argument, you must provide values (even if null or default values) for all of the arguments that come before it.

  4. #4
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Ed I'm not sure I understand email_send()2. Where do I enter the "Send To" address?

    EMAIL_SEND2( Message as P [, Profile as C [, Silent as L [, Store_in_Mailbox as L ]]] )

  5. #5
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,162

    Default Parameters in functions

    Parameters in functions fall into 2 basic categories. There are required parameters, and optional. The optional are shown as inside brackets []. You only have to supply the required parameters. For example, the email_send() function has 3 required parameters and 9 optional parameters. Parameters are separated by a comma. The letter in front of the parameter name indicates the type of value. "C" means character and will be in quotes. "N" is numeric and won't be entered with quotes. "L" is logical and with be either .T. or .F. If you place a value in an optional parameter, you don't use the brackets.

    For example, the required values for email_send would be as below as the function is displayed, and with values entered. You must enter text for the subject line.

    Code:
    email_send(C send_to, C subject,C message)
    
    email_send("BHPD104@aol.com","Email Notice","Form Has Data On It")
    If you want to supply the first optional parameter, a file attachment, the result would be something like this if the file to attach is "c:\myfile.txt"

    Code:
    email_send("BHPD104@aol.com","Email Notice","Form Has Data On It","c:\myfile.txt")
    It gets a bit more complicated if you want to use one optional parameter but skip the one listed before it. You still need to enter a value, but a blank is ok. For example, you may want to 'cc' (carbon copy) "otheremail@email.com" but not add an attachment. You still need a value in attachment, but it can be ""
    Code:
    email_send("BHPD104@aol.com","Email Notice","Form Has Data On It","","otheremail@email.com")
    You can replace a character parameter with a character variable
    Code:
    email_addr = "BHPD104@aol.com"
    subject = "Email Notice"
    body_text = "Form Has Data On It"
    
    email_send(email_addr,subject,body_text)

  6. #6
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,787

    Default

    Rich,

    Here's how I typically format for email_send(). The only thing odd about mine is that I get the profile from a defaults table rather than hard coding. And most of the other parameters would come from variables or table lookups as well.

    dim e_attach as c
    dim e_to as c
    dim e_prof as c
    dim e_body as c
    dim e_subj as c
    email_profile = lookup("<ADB_Path>\global_defaults",".t.","Email_profile")
    e_to = "me@mine.com"
    e_subj = "the subject"
    e_body = "the body of my email"
    e_attach = ""
    email_send(e_to,e_subj,e_body,e_attach,"","",.F.,"","",email_profile)
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  7. #7
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default

    From the help file:

    Code:
    dim message as P
    
    body = <<%a%
    Just wanted to let you know that we really enjoy using Alpha Five.
    %a%
    
    message.message = body
    message.to = "sales@alphasoftware.com"
    message.subject = "Thanks"
    email_send2(message, "", .F., .T.)

  8. #8
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Thanks for the help guys. I see my first mistake, I was wasn't putting quotation marks on each side of the email address, text message, etc. (I wish the user's manual had been more specific.)

    Anyway, I copied Jerry's expression to the "tee," and it still doesn't seem to be sending anything.

    Code:
    email_send("BHPD104@aol.com","Email Notice","Form Has Data On It")
    Is there something else I should be looking at? I've tested the A5 default email handler, and it sends the test message every time.

  9. #9
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default

    If it is appearing to send, but you are never receiving the message, try sending to a non-AOL account. We have had a lot of problems with AOL marking Alpha-mailed emails.
    [FONT=Tahoma][SIZE=1][COLOR=Blue]Aaron Brown
    Alpha Software Development Team[/COLOR][/SIZE][/FONT]

  10. #10
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Well all of the tests that I perform on the A5 mail handler come through to my AOL mailbox, it just doesn't seem to be coming in through the script.

  11. #11
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default

    Quote Originally Posted by Rich Hartnett
    Well all of the tests that I perform on the A5 mail handler come through to my AOL mailbox, it just doesn't seem to be coming in through the script.
    You just lost me. What isn't coming in through the script?

    Are you trying to download mail from an AOL account with Alpha Five's email_receive() function? That won't work.
    [FONT=Tahoma][SIZE=1][COLOR=Blue]Aaron Brown
    Alpha Software Development Team[/COLOR][/SIZE][/FONT]

  12. #12
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    No sorry Aaron, wrong terminology. I meant that if I send an email manually using the A5 mail handler or push the "test" button on the profile setup, it works fine sending to my AOL mailbox, but it does not seem to work using the expression in my WAS application.

    Check my attached screen shot to see if I have it set up correctly.

    (Also, I tried changing the "Send To" address to a non-aol account, and it didn't come through on that one either.)

  13. #13
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,636

    Default

    Rich, is this code running on the server fromt he same computer on which you are developing, or do you have a different server? If you have a different server, you will need to make sure you set up an email profile there first.

    Quote Originally Posted by Rich Hartnett
    No sorry Aaron, wrong terminology. I meant that if I send an email manually using the A5 mail handler or push the "test" button on the profile setup, it works fine sending to my AOL mailbox, but it does not seem to work using the expression in my WAS application.

    Check my attached screen shot to see if I have it set up correctly.

    (Also, I tried changing the "Send To" address to a non-aol account, and it didn't come through on that one either.)

  14. #14
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Normally I do the development work on a separate computer, but in this particular instance, I am doing the development work on the server itself, so I guess the answer to your question is "yes."

    Any clue as to why this isn't working?

  15. #15
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    I still can't get this to work, in case anyone has any ideas as to why.

  16. #16
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,787

    Default

    When I had unknown problems with this (server vs local) it was because of my email profile. Remember (as said below), when the email is being fired from the server, you have to set the SERVER's email profile. If you are using the latest verison of the WAS, right click on the server icon and pick Email Settings. Then test.

    Also, try putting default values for ALL of the arguments for email_send(). At one point I found I had to use the following before it would work (note I have a False for the argument to include the email in the outbox, that seemed significant in my case - the server does not have an email client, hence no outbox). Actually, try this solution first.

    email_send("me@me.com","","","","","",.F.,"","","")
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  17. #17
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Hi Steve

    Yes I've already set the email profile which I saved as the "default" profile in the server, and tested it several times. It fires and sends the email message every time during testing, it just won't send though the web form.

    I'll try your method and see what happens.

    Quote Originally Posted by Steve Wood
    When I had unknown problems with this (server vs local) it was because of my email profile. Remember (as said below), when the email is being fired from the server, you have to set the SERVER's email profile. If you are using the latest verison of the WAS, right click on the server icon and pick Email Settings. Then test.

    Also, try putting default values for ALL of the arguments for email_send(). At one point I found I had to use the following before it would work (note I have a False for the argument to include the email in the outbox, that seemed significant in my case - the server does not have an email client, hence no outbox). Actually, try this solution first.

    email_send("me@me.com","","","","","",.F.,"","","")

  18. #18
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Well I've been working on this problem for several weeks now and I still can't make it work.

    All I want to do is to send myself an email notification when someone hits the "Submit" button on one of my GRIDS. (Not a dialog) I assumed the correct place to insert the code on a grid would be the "Events - AfterUpdateRecords" section, but maybe that's not where I should be putting it.

    I tried Steve's example of using all defaults with the "email_send" code and still nothing happens. (See below)

    It should be noted that the default email handler has been set up and does send the test message correctly when pushing the "test" button.

    Here's what I'm trying and it's not working:

    HTML Code:
    email_send("rhartnett@berwynheightspd.com","","","","","",.F.,"","","")
    * The included pic shows where I'm placing the code.

    Does anyone know if I'm putting the code in the correct place, and what exactly is the correct code that I should be putting in? (It doesn't make any difference to me if "email_send()" or "email_send2() is used.)

    I simply want an email message sent to: rhartnett@berwynheightspd.com, with a message that says "Form has data on it."

    Any help is appreciated. (I'm running out of hair to pull out!)

  19. #19
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,162

    Default

    Rich

    I just sent you an email from a grid component using your code in the AfterUpdateRecords event. I was easily able to send an email to myself with this component. I have attached the component, which was built in AlphaSports. You can unzip it into a project in AlphaSports and test it.

    If you did not recieve the email, check for any blocked emails. It may have been marked as spam. If you did receive the email, but the component won't work on your server, then there is some issue with the email configuration on the server. Also, most spam filters block emails with the same send to and from address so if you are sending to yourself, it may get blocked.

  20. #20
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Yes I just got the email message from you. I'll look at the code and try it again tonight when I go back to work.

    Thanks Jerry.

  21. #21
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Jerry thanks a bunch for the info. The email notification is now working like a champ!

    I'm not sure why I couldn't get it to work for so long, but apparently I had something out of whack.

    Your code did the trick!

    Thanks again.

  22. #22
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,162

    Default

    Rich

    If you look at the difference between your code and mine, you will see that my code is included in the "AfterUpdateRecords" function defintion. The AfterUpdateRecords event calls that function. In your code, you did not define the function, but replaced it with just xbasic. When the function call was made, there was no function, therefore the code didn't run.

  23. #23
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,447

    Default

    Yeah I see that now. Thanks again.

  24. #24
    Member
    Real Name
    Prashant
    Join Date
    Aug 2011
    Posts
    69

    Default Re: Email_Send() Help

    Hi

    I did the same thing in my project

    But can you help me add a feature to it ?

    i want to insert data in the sql table if the link in the email is clicked

    is it possible ?

    Example :

    i have send an email once i submit the data in the grid

    the email has Approve and Disapprove link in it

    if i click on the link Approve

    the tables should have "Approved" filled in it

    here is what i tried

    <%A5

    Dim cn as sql::connection
    dim sqlCommand as c


    cn.open("::Name::MiniProject")

    sqlCommand = "Update Request_Details set Approval_Status = '" + ?Status + "' where Request_No = " + ?Request_No

    cn.Execute(sqlCommand)

    %>

    please help!!

Similar Threads

  1. email_send()
    By burtnco in forum Alpha Five Version 6
    Replies: 3
    Last Post: 11-14-2005, 09:35 AM
  2. Email_send
    By Steve Bovino in forum Alpha Five Version 6
    Replies: 7
    Last Post: 09-08-2005, 06:31 AM
  3. email_send errors
    By Antony in forum Alpha Five Version 6
    Replies: 1
    Last Post: 06-21-2005, 11:57 PM
  4. Using EMAIL_SEND with html content
    By Jonathan Earle in forum Alpha Five Version 6
    Replies: 3
    Last Post: 12-06-2004, 03:44 PM
  5. email_send FYI
    By Bill Warner in forum Alpha Five Version 5
    Replies: 2
    Last Post: 05-17-2004, 07:39 PM

Bookmarks

Posting Permissions

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