를 보내려고 할 때 : 그러나 attatchment하지 않는,오류 내가 이메일을 보내 내 프로그램에서 다음과 같은 기능을 사용하고 이메일 첨부 파일
def send_email(subject, sender, recipients, text_body):
FILE_TYPES = set(['txt', 'doc', 'docx', 'odt', 'pdf', 'rtf', 'text', 'wks', 'wps', 'wpd'])
form = ApplicationForm (request.files)
submit_name = form.file_upload.data.filename
mail = Mail(app)
msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body
if '.' in submit_name and submit_name.rsplit('.', 1)[1] in FILE_TYPES:
filename = secure_filename(submit_name)
form.file_upload.data.save('uploads/' + filename)
with app.open_resource(filename) as fp:
msg.attach(filename, fp.read())
mail.send(msg)
이메일이 올바른 사용자에게로 잘 작동하고 전송을, 파일 첨부 파일이 양식에서 오는 것처럼 잘못 참조 할 수 있습니다 믿습니다.
아래 기능을 사용하여 첨부 파일을 저장했지만 위와 같은 문제가 발생하지 않는 이유를 잘 알고 있습니다. 아무도 도와 줄 수 없습니까?
if '.' in submit_name and submit_name.rsplit('.', 1)[1] in FILE_TYPES:
filename = secure_filename(submit_name)
form.file_upload.data.save('uploads/' + filename)
return redirect('home')
편집 :받은 오류 메시지를 전송하려고 할 때입니다 :
[Errno 2] No such file or directory: 'C:\\Users\\richard.danvers\\application\\answer.docx'
은 '업로드'경로에 포함되지 않은 것처럼, 사람이를 포함하는 방법을 알고 같은데?
감사합니다. 수정 된 게시물. 다음 오류 메시지가 계속 나타납니다. [Errno 2] 해당 파일이나 디렉터리가 없습니다. 'C : \\ Users \\ richard.danvers \\ application \\ answer.docx' –