Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gmail attachment manager
#1
Hi all!

I was trying to find this in gmail plugins/labs but unsuccessfully.

Some of you who use gmail know that you can label your emails as you like. For ex if you got email from a BOB you can set label for this email as let say FRIEND, this helps you to locate emails quicker and so on. Gmail doesnt have any good attachment manager, so i`d like to have a macro - when i download attachment from email it will create folder on my HD named the same as the label (if doesnt exist) and save the attachment in this folder.

It can work with a trigger on currently opened email or intercept a mouse click or anything.

So any ideas how to do it? I work in a trading company and have to manage a lot of attachments from different people so it would greatly help my work! And also i found that many people would find it very helpful

BR
#2
Forgot to add that even better would be if it would save attachment like: create 'Label' folder inside create 'sender_name' folder and save attachment there.

Cant wait to see it work!
#3
What is your web browser?

----------------

I would try this:
Create new function.
Assign file trigger. Let it watch your downloads folder, so that your function runs when a new file added, ie when you download a file.
The function finds the label in web browser window. To find label, use function acc or htm.
Then the function creates folder with label name and moves the file there.
#4
I use opera v 10.00,

i have problems to get the label and 'from' value. Maybe its better to write a email client to download and manage attachments only? I think somebody tried that in QM already before. I just dont know if its possible with gmail.
#5
Email messages with attachments can be downloaded, but there is no label. Need to get label from web browser. It is possible in IE and Firefox and Opera.

Macro Macro1274
Code:
Copy      Help
Acc a=acc(" More actions[] " "GROUPING" win("Gmail - *" "IEFrame" "" 1) "Internet Explorer_Server" "" 0x1081 0 0 "next7 first child3 child7 first")
str label=a.Name
out label

Macro Macro633
Code:
Copy      Help
Acc a=acc("   More actions  " "BUTTONMENU" win("Gmail - *" "MozillaUIWindowClass" "" 1) "MozillaUIWindowClass" "" 0x1001 0 0 "parent5 next first5 next first next first child7 first")
str label=a.Name
out label

Macro opera label
Code:
Copy      Help
Acc a=acc("More actions" "STATICTEXT" win("Gmail - *" "OpWindow" "" 1) "id=0 OpWindow" "" 0x1001 0 0 "next first3 next2 first3")
str label=a.Name
out label
#6
this also gets from
Macro opera label
Code:
Copy      Help
Acc a=acc("More actions" "STATICTEXT" win("Gmail - *" "OpWindow" "" 1) "id=0 OpWindow" "" 0x1001)
Acc alab afrom
a.Navigate("next first3 next2 first3" alab)
a.Navigate("next2 first17" afrom)
str label=alab.Name
out label
str from=afrom.Name
out from
#7
Thanks it works.

I thought about how to proceed and i think this might be the simplest way (although not full automatic):

1. Open email message and Download attachments manually to folder C:\gmail
2. Trigger macro that:

A) mkdir C:\mail\"folder named as label"\"folder named as from"
B) ren "c:\gmail\*.*" "C:\mail\"folder named as label"\"folder named as from"

So how to use string var in path for mkdir and ren command? Is mkdir neccessary or macro can check when ren command is used if the folder exists and if not create it?
#8
Any ideas? I thought it should be easy, but cant find it in QM help.

Basically how to use str var to specify the path for ren command?
#9
str s
s.from("string" var "string" var ...)
ren s ...
#10
thanks, i have ended up with sth like this

Code:
Copy      Help
str path
str filename
str pfile

Acc a=acc("More actions" "STATICTEXT" win("Gmail - *" "OpWindow" "" 1) "id=0 OpWindow" "" 0x1001)
Acc alab afrom
a.Navigate("next first3 next2 first3" alab)
a.Navigate("next2 first17" afrom)
str label=alab.Name
out label
str from=afrom.Name
out from

path.from("C:\gmail\" label "\" from "\")
out path
mkdir path

int w1=act(win("Save As" "#32770"))
filename.getsel
out filename
pfile.from(path filename)
out pfile
outp pfile

When i open email and click attachment to download i trigger this macro and it creates folders and then saves file to this folder.

But i have a problem with

Code:
Copy      Help
a.Navigate("next2 first17" afrom)

sometimes it doesnt get the from name and sometimes macro stops and i get error "failed". Any ideas why? Cant really figure when this happens, maybe when the from name is unusual or sth. Also when email has more than 1 label it doesnt get the second label. Can i assign second label to another string?

Thanks,

PS. Out`s in the code just for my information.
#11
This is how to get all labels.
Macro opera label2
Code:
Copy      Help
out
Acc a=acc("More actions" "STATICTEXT" win("Gmail - *" "OpWindow" "" 1) "id=0 OpWindow" "" 0x1001)

Acc alab afrom asub
ARRAY(str) k ;;will store all labels here

a.Navigate("next first3" asub) ;;navigate from "More actions" to subject

int i
for i 2 1000
,_s.from("next" i " first3")
,asub.Navigate(_s alab) ;;navigate from subject to label
,err break ;;no more labels
,k[]=alab.Name

a.Navigate("next2 first17" afrom) ;;navigate from "More actions" to sender name
str from=afrom.Name

out "-- Labels --"
for i 0 k.len
,out k[i]

out "-- From --"
out from

Getting sender name fails when there are multiple messages displayed. Then I don't know how macro can detect from which message you are downloading attachment.

Gmail web page structure is complex and dynamic. Difficult to find accessible elements. Easier if you use internet explorer.
#12
Thanks, i also noticed that when using IE it`s easier to access the objects (dont know why though). Can you rewrite it for me so it works in normal IE 6 ? If it works then i can check my email in IE. This macro would save me so much time that running it in IE is lesser evil. In IE there will be no problem in getting Senders name? Maybe "show details" link next to sender name whould be helpful, did you see it?
#13
This is for IE 8. Did not test in IE 6, possibly will need to change some Navigate strings.
In Opera almost impossible because its accessible objects implemented incorrectly.

Macro Macro1274
Trigger Cg /IEXPLORE     Help - how to add the trigger to the macro
Code:
Copy      Help
;In Internet Explorer, Gmail message view, move mouse on Download link and run this macro.
;It extracts sender name and message labels.

Acc a alab afrom
a=acc(mouse) ;;Download link
str s=a.Name
if(s!"Download") mes- "Mouse pointer must be on Download link." "" "x"

a.Navigate("parent3") ;;table containing Download link
rep ;;search for beginning of message (there is no separate parent object for a message)
,a.Navigate("previous"); err mes- "Failed." "" "x"
,a.Role(s)
,if(s="GROUPING") break ;;the down arrow in the top-right corner of the message
,;note: I don't know, maybe message body also sometimes contains GROUPING. Then need more testing here.

a.Navigate("next first3 child3" afrom) ;;navigate from the down arrow to sender name
str from=afrom.Name

a.Navigate("parent child") ;;navigate from the down arrow to subject
str subject=a.Name

ARRAY(str) k ;;array for labels
a.Navigate("next") ;;skip Inbox table
rep ;;for each label table
,a.Navigate("next")
,a.Role(s)
,if(s!"TABLE") break
,a.Navigate("child7 first" alab) ;;get label
,k[]=alab.Name


out "-- From --"
out from
out "-- Subject --"
out subject
out "-- Label(s) --"
int i
for i 0 k.len
,out k[i]

;Now you have sender, subject and labels.
;Mouse pointer is on Download link...
#14
i have change the array part for label since i didnt know how to add multiple labels into my path. Any ideas?

I now have sth like this:

Code:
Copy      Help
;In Internet Explorer, Gmail message view, move mouse on Download link and run this macro.
;It extracts sender name and message labels.

str path
str filename
str pfile

Acc a alab afrom
a=acc(mouse) ;;Download link
str s=a.Name
if(s!"Download") mes- "Mouse pointer must be on Download link." "" "x"

a.Navigate("parent3") ;;table containing Download link
rep ;;search for beginning of message (there is no separate parent object for a message)
,a.Navigate("previous"); err mes- "Failed." "" "x"
,a.Role(s)
,if(s="GROUPING") break ;;the down arrow in the top-right corner of the message
,;note: I don't know, maybe message body also sometimes contains GROUPING. Then need more testing here.

a.Navigate("next first3 child3" afrom) ;;navigate from the down arrow to sender name
str from=afrom.Name

a.Navigate("parent child") ;;navigate from the down arrow to subject
str subject=a.Name

a.Navigate("next")
str k=a.Name

a.Navigate("next child7 first" alab) ;;get label
k=alab.Name


out "-- From --"
out from
out "-- Subject --"
out subject
out "-- Label(s) --"
out k


;Now you have sender, subject and labels.
;Mouse pointer is on Download link...

path.from("C:\gmail\" k "\" from "\")
out path
mkdir path

lef

wait 0 WE win("File Download" "#32770")
int w1=act(win("File Download" "#32770"))
's
wait 0 WC win("另存为" "#32770")

filename.getsel
out filename
pfile.from(path filename)
out pfile
outp pfile
'Y

so it works as i wanted. Although it would be cool to have multiple labels working. But i think for this i need to have ech label (lets say up to 3 labels) in str var like label1 label2 label3. Or myabe there is a way to do it with array too.

Is it a problem to also get the date and message body to string (maybe msg body to txt)?
#15
Quote:Is it a problem to also get the date and message body to string (maybe msg body to txt)?

To get date, use Navigate, like it is used to get other objects.
Getting message text is more difficult because it is parsed and mixed with attachment text. Alternatively the macro could click on the down arrow in the top-right corner, click 'Show original', wait for the new IE window, get raw message text (use htm), load the text into a MailBee.Message variable, and then it is easy to get all message parts, including attachments, or save whole message as eml file.


Forum Jump:


Users browsing this thread: 1 Guest(s)