Author Topic: Download and Read Email and attachments  (Read 4332 times)

wattsupnow

  • Newbie
  • *
  • Posts: 9
Download and Read Email and attachments
« 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?

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Download and Read Email and attachments
« Reply #1 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
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
Deana F.
Technical Support
Wilson WindowWare Inc.

wattsupnow

  • Newbie
  • *
  • Posts: 9
Re: Download and Read Email and attachments
« Reply #2 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!!

Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Download and Read Email and attachments
« Reply #3 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.
Deana F.
Technical Support
Wilson WindowWare Inc.

DAG_P6

  • Full Member
  • ***
  • Posts: 184
  • WinBatch rocks, and so does Wilson WindowWare!
    • WizardWrx
Re: Download and Read Email and attachments
« Reply #4 on: September 28, 2013, 02:36:08 pm »
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.
David A. Gray
You are more important than any technology.

rkoster

  • Newbie
  • *
  • Posts: 5
Re: Download and Read Email and attachments
« Reply #5 on: January 18, 2016, 12:15:19 pm »
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.