How to define a name of attachment in email with python ?

F

fowlertrainer

I want to set the name of the attachment in an python-generated email.

This is needed, because the another site we want to get this name, and
repack the attachments by name (an ID).

Some programming languges (components) are allow to set this.
(See Delphi/Indy/MessagePart)

fp=open(plist, 'rb')
mdata=MIMEAudio(fp.read(),'mpeg')
fp.close()
msg.attach(mdata)
???? msg['filename']='xxx'

Can anyone help in this problem ?

Thanx for it:
FT
 
P

Peter Hansen

I want to set the name of the attachment in an python-generated email.

This is needed, because the another site we want to get this name, and
repack the attachments by name (an ID).

Some programming languges (components) are allow to set this.
(See Delphi/Indy/MessagePart)

fp=open(plist, 'rb')
mdata=MIMEAudio(fp.read(),'mpeg')
fp.close()
msg.attach(mdata)
???? msg['filename']='xxx'

Can anyone help in this problem ?


Yes, read the manual: the online documentation of the email
module has some examples. The last example shows how to set
the filename (using msg.add_header() to set the Content-
Disposition header).

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top