Download Email Attachments

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Download Email Attachments

#1 Post by foncesa » 16 Feb 2014 22:37

Hello,

Is it possible to download the attachments from Yahoo email with Blat software and send the attachments to print if its *.XLS file.

Any suggestions.
Help required.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#2 Post by carlos » 16 Feb 2014 23:41

Hello. I never use blat, but it seems not have option for download attachments:

Code: Select all

Blat v3.1.2 (build : Dec 27 2013 14:33:12)
32-bit Windows, Full, Unicode

Windows console utility to send mail via SMTP or post to usenet via NNTP
by P.Mendes,M.Neal,G.Vollant,T.Charron,T.Musson,H.Pesonen,A.Donchey,C.Hyde
  http://www.blat.net


I have some stable code in java that I use for send e-mails with attachments, and also for download attachments, using the javamail library. If you are interested I can post it for use from command line like: java -jar (but it would need java).

foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Re: Download Email Attachments

#3 Post by foncesa » 17 Feb 2014 00:17

Thanks Carlos for response.

Definitely Carlos i want to give a try on that, but does it download the yahoo attachments, then surely i will use it.
Thanks in advance.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#4 Post by carlos » 17 Feb 2014 02:16

@foncesa.
What e-mail you want to download?
Example: not seen, recently ?

Each message have a message number, but for speedy for found a message you can apply filters, because is slow iterate throw all the messages in a e-mail folder. In this case the protocol is imap (this is not http), in this case you get via internet the header info of each message (because it is slow). The filter trick is get the messages done filtered by the server, that is different of get all messages from the server and filter in the client side.

Example: I want download the email from foo@foo.foo that as not seen, download the attachment and then mark as readed.
What is the method for select the message for download the attachment.
Obviously are the messages that have attachments. But for speedy, maybe you can specify a from address, because for know if the e-mail have a attachment you need read all the mail message and process it.

I can for example, print the last 10 messages from specific address that have attachments, showing the message number. Something like this:

Code: Select all

id from date
3 foo@foo.foo 2014-02-17
2 foo@foo.foo 2014-02-16
1 foo@foo.foo 2014-02-15


then download the attachment specifying the id

for speedy for found messages, you can redirect all the messages from specific address to a other specific folder, then search the messages in that folder that have only messages from the specific address. the default folder is inbox.

how you want specify the message that you want to download?
Edit: other filter is if the attachment name end with .xls or xlsx

npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Download Email Attachments

#5 Post by npocmaka_ » 17 Feb 2014 02:54

Just record your action with Chrome and export them to cURL queries. then all you need is cURL.exe.

foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Re: Download Email Attachments

#6 Post by foncesa » 17 Feb 2014 03:07

Hi,

Thanks Carlos,

I have an yahoo.com email and our 30 marketing executive upload an .xls files daily between 10a.m. to 1.p.m. I have
senders email address and they will upload the *.xls file only and on daily basis.

The script to download the attachments of this .xls files and send them to local printer for printer.
The script to recursively search with a pause of every 5 minutes on the server and any new is arrived it downloads and sends it to print.

Hope to have a favourable reply.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#7 Post by carlos » 17 Feb 2014 04:23

then the filter will be:

all the e-mails from a address for today.

foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Re: Download Email Attachments

#8 Post by foncesa » 17 Feb 2014 06:13

carlos wrote:then the filter will be:


.xls or .xlsx

The reason behind this filter i am using is i have kept this address only for receiving this .xls or .xlsx attachments.

all the e-mails from a address for today. YES.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#9 Post by carlos » 17 Feb 2014 06:33

what is the size approximately of the xls files ?
are there a distinct name?
example: 20140217.xls

or are like this:
report.xls

In the last case it would be renamed to
report_1.xls
report_2.xls

for avoid overwrite files.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Download Email Attachments

#10 Post by Squashman » 17 Feb 2014 08:53

foncesa wrote:Thanks Carlos for response.

Definitely Carlos i want to give a try on that, but does it download the yahoo attachments, then surely i will use it.
Thanks in advance.

Depends if Yahoo is allowing you POP3 or IMAP access to your mail. I know it hasn't always been free to do that with Yahoo. In the past they would make you pay for a premium account to have that access.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#11 Post by carlos » 17 Feb 2014 09:08

@foncesa: if you not can enable imap in yahoo because the account type, maybe you can use gmail.

I'm ready the first part, the download today files from a specific address, filtering by extension.
I need write the command line options for do the task.
At night, I will do. Now, I need program other thing for my job.
Last edited by carlos on 19 Feb 2014 01:01, edited 1 time in total.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Download Email Attachments

#12 Post by carlos » 17 Feb 2014 22:26

I'm ready the application, but for check for some adjustments, maybe I will post tomorrow.
I thinking in the for way of publish this. I would like the donationware system but if you need foncesa I always will send you.
You can enable imap on your yahoo account?


This is a output:
I'm use two mail accounts: one for send and other for download.

See the output:

C:\dev>echo hello i'm testing>test.txt

C:\dev>dir /b
terminalmail.jar
test.txt

C:\dev>java -jar terminalmail.jar

TerminalMail 0.1
Carlos Montiers <2014>

arguments (all case sensitive):
/mode:<string> send or downloadtoday
/user:<string> username
/pass:<string> password
/host:<string> host ip or domain
/port:<int> port number
/ssl enable ssl
/starttls enable starttls
/debug enable debug (optional)


downloadtoday mode (uses imap protocol):

/from:<string> the address from wich download attachments.
/extensions:<string;*> extension allowed for download attachments.
is is not specified all extensions are valids.

send mode (uses smtp protocol):

/from:<string> the address from send
/to:<string;*> the address to send
/cc:<string;*> cc address (this is optional)
/subject:<string> the subject
/text:<string> text message
/attachment:<string> the filename attachment (only one) (this is optional)



C:\dev>java -jar terminalmail.jar /mode:send /user:*********@*****.com /pass:********************* /host:smtp.gmail.com /port:587 /auth /starttls "/from:Carlos <*********@*****.com>" /to:******@******.com "/subject:A test" "/text:See the file." /attachment:test.txt

C:\dev>echo %errorlevel%
0

C:\dev>del test.txt

C:\dev>dir /b
terminalmail.jar

C:\dev>java -jar terminalmail.jar /mode:downloadtoday /user:******@******.com /pass:****************** /host:imap.gmail.com /port:993 /ssl "/from:cmontiers@gmail.com" /extensions=.txt
Message: A test
Saving test.txt ...

C:\dev>echo %errorlevel%
0

C:\dev>dir /b
terminalmail.jar
test.txt

C:\dev>type test.txt
hello i'm testing

C:\dev>


Post Reply