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

Download Email Attachments

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

    Download Email Attachments

    Is there a way for me to download an email attachment into a diroctory....
    My client receives zip files, and wants this to be automated... Without him having to manually downloading from his email the attachement for use into the Alpha database I created for him...

    I tried this but does not seem to work:
    email_pop_open(pSocket, "mail.yahoo.com", "username", "pass")= .T.
    email_pop_retr(pMessage, pSocket,1)= .T.
    email_save_attach(pMessage)=C:\Program Files\AlphaUno\JGNT\test.zip

    also, would need to send subject to only downoad files needed...

    Thanks for the help

    Judith

    #2
    Re: Download Email Attachments

    Judith,

    I am also trying to automate processing of incoming e-mails. In my system, incoming messages should have "Invoice Batch" as the subject and 2 CSV attachments with names starting with "BatchInvHdr" and "BatchInvItm". The script warns the user if a message is received with a different subject or attachment names. If the subject and attachments are OK, it runs scripts to import the data from the CSV files into the database.

    My code is:

    Code:
    vcPOPSvr = alltrim(lookupc("F", 1, "POP_svr", "emailsetup", ""))
    vcPOPUser = alltrim(lookupc("F", 1, "POP_user", "emailsetup", ""))
    vcPOPPassword = alltrim(lookupc("F", 1, "POP_pw", "emailsetup", ""))
    
    'Open incoming e-mail connection
    statusbar.Set_Text("Logging on to incoming e-mail server...")
    Logon:
    vlLogOnOK = email_pop_open(ps, vcPOPSvr, vcPOPUser , vcPOPPassword)
    IF vlLogOnOK THEN
    	vnNumMsg = ps.nMessages	
    	IF vnNumMsg = 0 THEN
    		msgbox("No messages", "No incoming e-mail messages found.", UI_ATTENTION_SYMBOL + UI_OK)
    	ELSE
    		statusbar.Set_Text("Processing incoming e-mail...")
    		FOR i = 1 to vnNumMsg
    			vcHeader = email_pop_headers(ps, i)
    			vcSubject = a5_email_get_field(vcHeader, "Subject:")
    			IF vcSubject = "Invoice Batch" THEN
    				vlRecOK = email_pop_retr(pm, ps, i, .T.)
    				IF vlRecOK = .T. THEN
    					vcAttachList = email_save_attach(pm)
    					FOR EACH item in vcAttachList
    						vcAttachment = item.value
    						vcAttachFile = file.filename_parse(vcAttachment, "ne")
    						IF left(vcAttachFile, 11) = "BatchInvHdr" THEN
    							script_play("ProcessInvHeader")
    						ELSEIF left(vcAttachFile, 11) = "BatchInvItm" then
    							script_play("ProcessInvItems")
    						ELSE
    							msgbox("Check attachment", "There is a message with subject 'Invoice Batch' and an attachment called" \
    							+ vcAttachFile + ".", UI_ATTENTION_SYMBOL + UI_OK)
    						END IF
    					NEXT
    				ELSE
    					msgbox("Error!", "Error retrieving message", UI_STOP_SYMBOL + UI_OK)
    				END IF
    			ELSE
    				msgbox("Warning!", "There is a message with the subject '" + vcSubject + "' on the server.", UI_ATTENTION_SYMBOL + UI_OK)
    			END IF
    		NEXT i
    	END IF
    ELSE
    	vnResp = msgbox("Log-on Error", "Failed to log on to incoming mail server.", UI_STOP_SYMBOL + UI_RETRY_CANCEL)
    	IF vnResp = ui_retry_selected THEN
    		GOTO Logon
    	ELSE
    		msgbox("Logon Cancelled", "User aborted logon" , UI_INFORMATION_SYMBOL + UI_OK)
    	END IF
    END IF
    
    email_pop_close(ps)
    This has been working for the last few days, but today the email_pop_open statement won't log on to my POP server. Does anyone know why this works intermittently?

    Thanks,
    Tony

    Comment


      #3
      Re: Download Email Attachments

      Tony,

      was trying your code and found that vlLogonOk would always come out false... I use Yahoo and had put "mail.yahoo.com"... When that did not work I changed it to "pop.mail.yahoo.com" and it worked...

      Maybe you have the same problem for your ISP...

      Hope this helps

      Judith

      Comment


        #4
        Re: Download Email Attachments

        Judith,

        Thanks for your reply.

        The variables vcPOPSvr, vcPOPUser and vcPOPPassword get their values from emailsetup.dbf. The server, user name and password are correct - I have managed to connect and download messages using this code.

        I has an intermittent problem connecting - it worked from Monday to Wednesday, stopped working this morning, worked from 11am to 1pm today (UK time), and now works again.

        I have checked the buffer and found that the log-on is timing out. This also happens intermittently in the interactive window. I will check with my ISP - they might be able to identify the problem.

        I'm sorry, I have taken over your thread with my problem. Going back to your original question, I can't see any way to control the folder that attachments are saved into, apart from using View-Settings-Email, but after saving them, you can then use Xbasic to rename or move them etc.

        I don't understand the last sentence of your original post - "also, would need to send subject to only downoad files needed...". Can you tell me what you want the code to do?

        Tony

        Comment


          #5
          Re: Download Email Attachments

          No problem with using this tread with your issue... as for my issue I used smatch_to(vcSubj, "*UNO*") to find the email i want to download... as for attachment i will keep looking...
          The Alpha help on email_save_attach is not much help... I don't understand how it works and where it saves the attachment... I have a table a_email.dbf in my database but see nothing in there...

          Anyway

          will try to see if i can make it work..

          Judith

          Comment


            #6
            Re: Download Email Attachments

            Judith,

            I think email_save_attach just saves attachments into the folder specified in View-Settings-Email (default is 'attachments' subfolder of the A5V7 program folder) and returns a list of the path/file names.

            I can't find a way in XBasic to change the folder that the attachments are saved into, but you can use the file name information returned by email_save_attach to process the attachments in any way you want with XBasic, e.g rename, copy, move, import etc.

            Tony

            Comment


              #7
              Re: Download Email Attachments

              Thanks

              I did setup that folder to the one where I want the attachments but nothing happens... That is why I don't get it... It says downloading but no files is saved...

              Judith

              Comment


                #8
                Re: Download Email Attachments

                Judith,

                You could try the following code:

                Code:
                dim vcAttachList as c
                dim vcFile as c
                vcAttachList = email_save_attach(pm)
                FOR EACH item in vcAttachList
                	vcFile = item.value
                	msgbox(vcFile)
                NEXT
                The message box should tell you where the attachments are.

                Tony

                Comment


                  #9
                  Re: Download Email Attachments

                  Thanks Tony

                  I just figured out why I did not get anything... I was using the same email address to re send the test email... I used another one to send to my yahoo email and got it to work...
                  Thanks again for all the help... Hope you were able to work out you issue...

                  Judith

                  Comment


                    #10
                    Re: Download Email Attachments

                    When I run this code the status bar etx text says dowloading file but no file is saved in the directory...
                    email_pop_retr(pm, pSocket, i, .F.)
                    email_save_attach(pm)

                    The only way the attachment is saved is if I use the alpha mail reader...is there a way around this or do I have to use the Alpha 5 mail reader...

                    Judith

                    Comment


                      #11
                      Re: Download Email Attachments

                      Judith,

                      Have you tried adding my code to your script after the email_pop_open and email_pop_retr statements? This should help you to diagnose the problem.

                      Tony

                      Comment


                        #12
                        Re: Download Email Attachments

                        Yes I did, I see the path and file name in vcfile but when I look in the folder on my pc there is nothing...
                        Judith

                        Comment


                          #13
                          Re: Download Email Attachments

                          Judith,

                          That's weird - I don't understand why it would do that. If any of the Alpha gurus are reading this, perhaps they can suggest a solution?

                          Tony

                          Comment


                            #14
                            Re: Download Email Attachments

                            I download email several times every day. Sometimes there are 20 to thirty. I don't have to handle attachments, but remember that the email set up has a place in the recieving box for attachments. it has \intlead or something like that in the attachments box. I do this from a form with a button. I have a folder under my app by that name, just in case.

                            It appears you are trying to do all of it with code which is admirable.

                            Good Luck to you!

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

                            Comment


                              #15
                              Re: Download Email Attachments

                              Dave,

                              The system I am designing allows suppliers to create invoices for direct deliveries to my client's customers. At the end of each day, the supplier runs a script which prints the invoices and a daybook report, then creates CSV files containing details of invoice headers and invoice items, and e-mails them to my client.

                              Every morning, the client will run a script which downloads the e-mails from all the suppliers and checks whether they have the correct subject and attachment names, then imports the attachments into temporary tables and appends these tables to the main invoice tables.

                              So, for both the supplier and the client, there is only one button click (plus a couple of confirmation dialogs) each day to transfer all the invoice data.

                              Tony

                              Comment

                              Working...
                              X