4
from manager import ustr
7
sub = (mail.Subject).replace(' ','')
8
body = mail.Body.encode("utf-8")
9
recipients=mail.Recipients
10
sender=mail.SenderEmailAddress
11
attachments=mail.Attachments
13
email = chilkat.CkEmail()
14
email.put_Subject(ustr(sub).encode('iso-8859-1'))
15
email.put_Body(ustr(body).encode('iso-8859-1'))
16
email.put_From(ustr(sender).encode('iso-8859-1'))
18
for i in xrange(1, recipients.Count+1):
19
name = ustr(recipients.Item(i).Name).encode('iso-8859-1')
20
address = ustr(recipients.Item(i).Address).encode('iso-8859-1')
21
email.AddTo(name,address)
23
eml_name= ustr(sub).encode('iso-8859-1')+'-'+str(mail.EntryID)[-9:]
24
ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|']
26
attachments_folder_path = os.path.abspath(os.path.dirname(__file__)+"\\dialogs\\resources\\attachments\\")
27
if not os.path.exists(attachments_folder_path):
28
os.makedirs(attachments_folder_path)
29
for i in xrange(1, attachments.Count+1):
30
fn = eml_name + '-' + ustr(attachments[i].FileName).encode('iso-8859-1')
40
fn = f[0][0:l] + '.' + f[-1]
41
att_file = os.path.join(attachments_folder_path, fn)
42
if os.path.exists(att_file):
45
attachments[i].SaveAsFile(att_file)
46
contentType = email.addFileAttachment(att_file)
47
if (contentType == None ):
48
print mail.lastErrorText()
51
mails_folder_path = os.path.abspath(os.path.dirname(__file__)+"\\dialogs\\resources\\mails\\")
52
if not os.path.exists(mails_folder_path):
53
os.makedirs(mails_folder_path)
55
eml_name = eml_name.replace(c,'')
56
if len(eml_name) > 64:
57
l = 64 - len(eml_name)
58
f = eml_name.split('-')
59
eml_name = f[0][0:l] + '.' + f[-1]
60
eml_path = ustr(os.path.join(mails_folder_path,eml_name+".eml")).encode('iso-8859-1')
61
success = email.SaveEml(eml_path)
62
if (success == False):
63
print email.lastErrorText()
66
print "Saved EML!",eml_path
b'\\ No newline at end of file'