• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Save and Rename mail attachments

#1 2012-01-27 14:57:10

ponzio
Member
Registered: 2008-10-01
Posts: 13

Save and Rename mail attachments

Hi.
I need to download and rename mail attachments.
I'm daily receiving an email whose subjects contain the date while the attachment name is always the same.
I need to save the attachment and RENAME it with the mail subject.

Please help.

Many thanks, in advance,
Andrea

Offline

#2 2012-01-29 04:47:48

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Save and Rename mail attachments

Hi Andrea

You can use tPOP component to fetch mail, use tFileInputMail to export attachments.
Then use tFileCopy to rename attachments.

Best regards,
Pedro


Only Paranoid Survive.

Offline

#3 2012-01-30 08:52:26

ponzio
Member
Registered: 2008-10-01
Posts: 13

Re: Save and Rename mail attachments

Hi Pedro.
Thanks for your answer ....

Just a couple of questions:

1) using the tInputMail I've the problem that it overwrites the attachments file if I'm gettingm ore than one un-read email ...
a possibile workaround is to extract only one email anceh then using a LOOP to downaload all the emails...any other ideas ?

2) using the tFileCopy, how can I pass to it the email subject to compose the new attachment name ? (sorry but I'm very new using Talend)

Thanks,
Andrea

Offline

#4 2012-01-30 09:21:35

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Save and Rename mail attachments

Hi Andrea

1)
You can set "Attachment export directory" of tFileInputMail like this to avoid overwriting.

Code:

"E:/Attachment/"+context.sequence+"/"                   //context.sequence will be increased by tJava(context.sequence++)

Export each attachment into an unique directory.
2) You can set "Mail parts" of tFileInputMail as follows. Then extract this field into a variable.

Code:

Column   Mail part
Object     "Subject"

Regards,
Pedro


Only Paranoid Survive.

Offline

#5 2012-01-30 10:05:13

ponzio
Member
Registered: 2008-10-01
Posts: 13

Re: Save and Rename mail attachments

1) You can set "Attachment export directory" of tFileInputMail like this to avoid overwriting.

Code:

"E:/Attachment/"+context.sequence+"/"                   //context.sequence will be increased by tJava(context.sequence++)

Ok, I'm going to try this ... but I'll nedd a way to give the exact name (related to the subject) to the proper directory attachment ...

2) You can set "Mail parts" of tFileInputMail as follows. Then extract this field into a variable.

Code:

Column   Mail part
Object     "Subject"

I did it .. I'm writing a csv file with the sender and subject of the downloaded emails ...
My problem is to pass the subject to che tCOPY.

Thanks,
Andrea

Offline

#6 2012-01-30 10:10:55

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Save and Rename mail attachments

Hi Andrea

To pass the subject to tCopy.
You can create job as the following images with the csv file.

Regards,
Pedro


Uploaded Images


Only Paranoid Survive.

Offline

#7 2012-01-30 10:44:20

ponzio
Member
Registered: 2008-10-01
Posts: 13

Re: Save and Rename mail attachments

It works !

Many many thanks

Offline

#8 2012-01-30 14:26:28

ponzio
Member
Registered: 2008-10-01
Posts: 13

Re: Save and Rename mail attachments

Just another question ... is it possible to get the attachment name ?

Andrea

Offline

#9 2012-01-31 02:29:57

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Save and Rename mail attachments

Hi

No. It's impossible to get the attachment name directly now.

Regards,
Pedro


Only Paranoid Survive.

Offline

#10 2012-05-04 14:47:48

st_germain
New member
Registered: 2012-04-28
Posts: 5

Re: Save and Rename mail attachments

Hi, can you please explain exactly, how I can detach the attachments with tInputMail?
The original filename is in my case in the subject ...

Offline

#11 2012-05-07 04:30:19

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Save and Rename mail attachments

Hi St_germain

tFileInputMail can detach attachments automatically if you offer correct path for "Attachment export directory".

Regards,
Pedro


Only Paranoid Survive.

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Save and Rename mail attachments

Board footer

Powered by FluxBB