Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help with bad Code for sending email

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

    Help with bad Code for sending email

    In the following code is to send an email using A5 email client and the body of email template. The email is sent ok with the attachments but the body of the email is unreadable (all codes). The code below comes from AS. There is something wrong with the syntax but unable to see where; it's way above my XBasic skills. Help will be much appreciated.
    This is the code from A.S.
    Code:
    'Send an e- mail message using the Alpha Five e-mail clilent.
    if is_object(topparent.this) then 
    	form_name = topparent.name()+".this"
    else
    	form_name = ""
    end if
    Dim message_type as c 
    message_type = ""
    _to_var  = a5_eval_expression("=Lookup(\"customers\", \"Custid_pk=\"+s_quote(Attendances->Custid_Fk), \"alltrim(email1)\")",local_variables())
    param_to = _to_var
    subject_var  = a5_eval_expression("=\"Reading Material for Session \"+Sessdate",local_variables())
    param_subject = subject_var
    param_cc = ""
    param_bcc = ""
    attachments_var  = a5_eval_expression("=Var->zattachmts",local_variables())
    param_attachments = attachments_var
    template_text = a5_get_saved_email("HandoutTMessageBody")
    dim em as p
    'A5_email_parser() parses out the different sections of the e-mail template
    em = a5_email_parser(template_text)
    'Evaluate any mailmerge commands that may exist in the template by calling the a5_mailmerge() function.
    param_message = em.message_body_temp
    param_message = a5_mailmerge(param_message,form_name)
    'Put attachment into a zip file
    zipfile = file.temp_create(file.temp_path_get())+".zip"
    zip_files(zipfile,attachments_var,.t.)
    param_attachments = zipfile
    'Send the e-mail message directly - do not open the Alpha Five e-mail client
    send_result = email_send(param_to,param_subject,param_message,param_attachments,param_cc,param_bcc,.t.,message_type)
    if send_result <> 1 then
    	ui_msg_box("Error","E-mail message was not sent.",UI_STOP_SYMBOL)
    end if
    This is how the email arrives:

    <link rel="stylesheet" type="text/css" media="screen" href="a5res:defaultStyle\(default)"/><html><head><meta name="generator" content="Alpha Five HTML Editor"><title></title><style><!--p { margin-top: 0; margin-bottom: 0 }--></style></head><body><table width="90%" border="1" bordercolor="#ffffff" cellpadding="0" cellspacing="0" background="" > <tr> <td> <FONT size=2>Hello Somebody : </FONT></td> </tr> <tr> <td> <FONT size=2>We missed you at the OCTOBER 23, 2009 Group Monthly Meeting.<BR>To keep you informed, I have attached the handouts from that session.

    Thanks in advance

    #2
    Re: Help with bad Code for sending email

    Gaby,

    The problem with AS is that there is overkill in all of the code. I can't even begin to see where your code is going south, but I have included a simple automated e_mailing routine that pushes out 70 letters every 6 hours. I think that the "A5_Email_parse" code is giving you grief.

    Here is a simple example of the whole thing:

    Code:
    pdf_filename = "C:\Forecast\reports"+chr(92)+trim(tbl1.location)+"_Pavement_forcast.pdf"
    msg_text = "Attached is the Pavement Condition Forcast for "+strtran(tbl1.location,"_"," ")
    param_to = trim(tbl1.Email_addr)
    param_subject = alltrim(strtran(tbl1.location,"_"," "))+" Pavement Condition Forcast"
    param_cc = ""
    param_bcc = ""
    param_msg = msg_text
    param_attachments = pdf_filename
    email_Send(param_to,param_subject,param_msg,param_attachments)
    This code is embedded in a loop that goes through a table of locations and e_mail addresses. The body text is always the same, and the subject and addressee change with each record.

    Hope it helps,

    Tom

    Comment


      #3
      Re: Help with bad Code for sending email

      If the body is garbled, then it has to do with any or all of the following functions:
      a5_get_saved_email()
      a5_email_parser()
      a5_mailmerge()
      all of which are internal functions, meaning either:
      1-attach a zip file for confirmation, or
      2-you need Lenny Forzati to help you with this. He might jump in here,
      3-if not send a bug report.

      Comment


        #4
        Re: Help with bad Code for sending email

        Hi Tom:
        Thanks for sharing your code.
        As I already said a few times before, A5 has really superb features... superb when they work. For expl, the fact that one can create an email template, dress it up the way you want and being able in AS to choose if you want to use the header only or the body only or both is just fantastic. But when you choose to use the body only, A5 generates a bad code. After hours of frustration, comparing and testing I found out that the problem comes from the - message_type = "" - variable, should be: message_type = em.style and should be moved a few lines below. Bugs like this is like a hair in a scrumptious soup. Then when I had this fixed, I said to myself since Xmas is just a few days away let's add a small xmas/happy holidays image to the template. The finished template looked just great. I ran a few tests and wham another hair in the soup, the image didn't travel with the email.

        Comment


          #5
          Re: Help with bad Code for sending email

          Sorry to hear about the hair. Haven't really used templates or AS, so I really can't be of any real help here.

          The only suggestion would be to view the x-basic for Glaring errors. If you find the error, convert the AS to x-basic, fix the error, and use that code.

          Tom

          Comment


            #6
            Re: Help with bad Code for sending email

            soup??

            Notified a waiter in North Carolina there was a fly in my soup. He responded: " Don't say it too loud or everybody will want one"

            In Georgia: Asked the waiter what a fly was doing in my soup? He responded: " Looks like the back stroke"

            Have a good one today!

            .
            Dave Mason
            [email protected]
            Skype is dave.mason46

            Comment


              #7
              Re: Help with bad Code for sending email

              Hi All
              I use a similar configuration, but I want to attached two files with their full paths stored in variables. When using the one variable as an attachment, it works fine. I just do not know how to concatenate it with proper syntax the way Alpha requires it. See below:

              pdf_filename = "C:\Forecast\reports"+chr(92)+trim(tbl1.location)+"_Pavement_forcast.pdf"
              msg_text = "Attached is the Pavement Condition Forcast for "+strtran(tbl1.location,"_"," ")
              param_to = trim(tbl1.Email_addr)
              param_subject = alltrim(strtran(tbl1.location,"_"," "))+" Pavement Condition Forcast"
              param_cc = ""
              param_bcc = ""
              param_msg = msg_text
              param_attachments = variable1+";"+ variabl2
              email_Send(param_to,param_subject,param_msg,param_attachments)

              Any pointers would be appreciated
              Thanks
              Peter Gagiano

              Comment


                #8
                Re: Help with bad Code for sending email

                The genie seems to want to create a crlf() delimited list rather than using the semicolon.

                Try

                Code:
                pdf_filename = "C:\Forecast\reports"+chr(92)+trim(tbl1.location)+"_Pavement_forcast.pdf"
                msg_text = "Attached is the Pavement Condition Forcast for "+strtran(tbl1.location,"_"," ")
                param_to = trim(tbl1.Email_addr)
                param_subject = alltrim(strtran(tbl1.location,"_"," "))+" Pavement Condition Forcast"
                param_cc = ""
                param_bcc = ""
                param_msg = msg_text
                attachment_list = <<%a%
                [varC->variable1]
                [varc->variabl2]
                %a%
                param_attachments =  replace_parameters(attachment_list,local_variables())
                email_Send(param_to,param_subject,param_msg,param_attachments)
                There can be only one.

                Comment


                  #9
                  Re: Help with bad Code for sending email

                  Hi Stan
                  Thanks for the pointer.I am getting the "alias required" error message. Here is my altered code:
                  dim message_type as c
                  dim firstAttach as c
                  dim secondattach as c
                  firstAttach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".html"
                  secondattach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".pdf"
                  message_type = ""
                  param_to = ""
                  param_subject = "Booking Confirmation"
                  param_cc = ""
                  param_bcc = ""
                  param_message = "message_text"
                  param_alias = "Alias Name"
                  attachment_list = <<%a%
                  [varC->firstAttach]
                  [varc->secondattach]
                  %a%
                  param_attachments = replace_parameters(attachment_list,local_variables())
                  email_client_external(param_to,param_subject,param_message,param_attachments,param_cc,param_bcc)

                  Thanks
                  Peter Gagiano

                  Comment


                    #10
                    Re: Help with bad Code for sending email

                    Where did this come from?

                    param_alias = "Alias Name"

                    Shouldn't you have some name or field here?

                    param_to = ""
                    There can be only one.

                    Comment


                      #11
                      Re: Help with bad Code for sending email

                      Hi Stan
                      I want the mail client to pop up ant the user will decide what email address to put in.
                      The alias thing: I do not need it. just copied it from sample code somewhere. It pops up "alias required" error message even when commenting out the following line.
                      param_alias = "Alias Name"

                      Thanks
                      Peter Gagiano

                      Comment


                        #12
                        Re: Help with bad Code for sending email

                        Try this.

                        Code:
                        rslt = ui_get_text("Recipient","Enter email address","[email protected]")
                        dim message_type as c 
                        dim firstAttach as c
                        dim secondattach as c
                        firstAttach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".html"
                        secondattach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".pdf"
                        message_type = ""
                        param_to = rslt
                        param_subject = "Booking Confirmation"
                        param_cc = ""
                        param_bcc = ""
                        param_message = "message_text"
                        'param_alias = "Alias Name"
                        attachment_list = <<%a%
                        [varC->firstAttach]
                        [varc->secondattach]
                        %a%
                        param_attachments = replace_parameters(attachment_list,local_variables())
                        email_client_external(param_to,param_subject,param_message,param_attachments,param_cc,param_bcc)
                        There can be only one.

                        Comment


                          #13
                          Re: Help with bad Code for sending email

                          I still get alias required message. The reason for me wanting to open the email client is that the user must still be able to write a message before sending it. See attached image

                          Thanks

                          Comment


                            #14
                            Re: Help with bad Code for sending email

                            Peter,

                            here is a simplified piece of code that emails a pdf report to 2 other people in the agency. I get the email message to pop before I send it so that I can add or change any text.

                            Code:
                            Report.saveas("Medicaid Payment Listing","PDF",query.filter,query.order,pdf_filename)
                            
                            msg_text = "attached is the Medicaid Payment Listing for "+textname
                            param_to = "Cafone, Michelini"
                            param_subject = TEXTNAME+" Medicaid Payment Listing"
                            param_cc = ""
                            param_bcc = ""
                            param_msg = msg_text
                            param_attachments = pdf_filename
                            
                            email_client_external(param_to,param_subject,param_msg,param_attachments)
                            Tom
                            Last edited by Tom Henkel; 12-09-2009, 04:59 PM. Reason: I take it back.

                            Comment


                              #15
                              Re: Help with bad Code for sending email

                              HI all
                              Thank you for all the help on this but there is still something sticky here that I cannot fathom out.
                              Tom, my default email is set to outlook.
                              As soon as I replace this:
                              param_attachments = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".html"

                              with this to cater for an additional attachment:
                              dim firstAttach as c
                              dim secondattach as c

                              firstAttach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".html"
                              secondattach = A5.GET_PATH()+chr(92)+"invoices"+chr(92)+vIVSelect+".pdf"

                              attachment_list = <<%a%
                              [varC->firstAttach]
                              [varc->secondattach]
                              %a%
                              param_attachments = replace_parameters(attachment_list,local_variables())

                              I get the "alias required" error message.
                              Any help on this would be appreciated.

                              Thanks
                              Peter Gagiano

                              Comment

                              Working...
                              X