WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: wattsupnow on September 27, 2013, 08:11:40 AM

Title: Download and Read Email and attachments
Post by: wattsupnow on September 27, 2013, 08:11:40 AM
Morning! I was wondering if winbatch can do the following. 

Currently we have our clients send us an email with attachment (csv, excel) to a inbox. Then I have PMAIL download the emails and attachments from the server to our box (pc). with in PMAIL i have filters setup to place certain clients and attachments in folders on the harddrive. Now I have 10 winbatch scripts running on a timer (every 5-15 mins) to check the folders, if any attachment (csv, excel) is found in these folders take these files and upload to our main frame. This has been working great! but would like to have winbatch handle every from getting the email and attachments to placing in correct folder, then process it.

So long story short - can winbatch download emails with attachments from hosting server and read the attachments? if so, anyone have some sample scripts?
Title: Re: Download and Read Email and attachments
Post by: Deana on September 27, 2013, 08:23:33 AM
Sounds like a job for  the Postie Extender kGetMail function.

Here is a simple code sample:
Code (winbatch) Select

AddExtender("WWPST44I.DLL")
host="mail.server.com"
fromaddr="user@server.com"
userid="username"
password="pswd"
port=""
msgnumber=""
extractfile=""
mailbox=""
flags=""
kInit(host,fromaddr,userid,password,port)
While 1
   DirChange("c:\temp\attachments")
   allmsgs=kGetMail(msgnumber,extractfile,"",mailbox,flags)
   TimeDelay(1)
EndWhile
Exit


Reference:  http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/Postie+kGetMail~attachments.txt
Title: Re: Download and Read Email and attachments
Post by: wattsupnow on September 27, 2013, 08:39:35 AM
Thanks for the quick reply! I will have used that before to send emails. Will take a look at it thanks!!
Title: Re: Download and Read Email and attachments
Post by: Deana on September 27, 2013, 08:42:49 AM
The key here is that you call the DirChange before the kGetMail to specify where to place the file attachments.
Title: Re: Download and Read Email and attachments
Post by: DAG_P6 on September 28, 2013, 02:36:08 PM
Quote from: Deana on September 27, 2013, 08:42:49 AM
The key here is that you call the DirChange before the kGetMail to specify where to place the file attachments.

Another option, especially of the destination depends on the content of the files, download everything to one folder, then use FileMove, FileCopy, or similar shell extender functions to move them around.
Title: Re: Download and Read Email and attachments
Post by: rkoster on January 18, 2016, 12:15:19 PM
Quote from: DAG_P6 on September 28, 2013, 02:36:08 PM
Quote from: Deana on September 27, 2013, 08:42:49 AM
The key here is that you call the DirChange before the kGetMail to specify where to place the file attachments.

Another option, especially of the destination depends on the content of the files, download everything to one folder, then use FileMove, FileCopy, or similar shell extender functions to move them around.