I have a script that sends files to a bunch of different vendors. So the contents part changes every iteration. It works perfectly sending one attachment, but when I add another path in either the contents section ( and I have also tried) the .send() portion it still only sends one attachment.
Also, a weird part is that it only sends the new file and not the one I have been sending for a while that was working.
I have tried adding the multiple attachments to the contents section:
contents=['Hi '+ vendor_info[vendor_count][0] +
'irrelevant text', attachment, instruction_doc]
*I have tried creating a list of the file paths using it in the.send() *
attachments = [attachment, instruction_doc]
yag.send(recipient,subject,contents,attachments)
In both of these examples, when I receive the test email, the only attachment I receive is the instruction document*
Here is some more code to provide a better understanding:
#reads from config file where the folder of files is
#can be changed via gui menu
vendor_attach_directory = (parser.get(
'VendorFile', 'File_Location') + "/")
instruction_doc="C:/Users/Ryan/Desktop/instructions.txt "
while vendor_count < num_vendors:
recipient = vendor_info[vendor_count][1]
subject = 'Open PO Report' + ' for ' + vendor_info[vendor_count][0]
attachment = vendor_attach_directory +'testdoc.txt'
attachments = [attachment,instruction_doc]
if os.path.isfile(attachment) == True:
pass
else:
vendor_no_attach.append(vendor_info[vendor_count][0])
vendor_count += 1
continue
contents = ['Hi '+ vendor_info[vendor_count][0] +
'irrelevant text']
try:
yag.send(recipient, subject, contents, attachments)
except yagmail.error.YagInvalidEmailAddress:
invalid_emails.append(vendor_info[vendor_count])