
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
colab에 엑셀 파일 업로드 하는 방법에 대해 다시 한 번 설명 부탁드려요.
코드를 실행하면 하기 내용 같은 오류가 발생했다고 확인이 됩니다.
'이 오류는 openpyxl.load_workbook() 함수가 지정된 경로에서 강리현_고객리스트.xlsx 파일을 찾을 수 없기 때문에 발생합니다. 파일이 올바른 경로에 있는지 확인해야 합니다.'
작성한 코드 및 에러 메세지
import openpyxl
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# 엑셀 파일 경로 설정
excel_file = '강리현_고객리스트.xlsx'
# 이메일 보낼 계정 설정
email = "your_email@example.com"
password = "your_password"
# 이메일 서버 설정
smtp_server = "smtp.example.com"
smtp_port = 587
# 엑셀 파일에서 이메일 주소 가져오기
wb = openpyxl.load_workbook(excel_file)
sheet = wb['고객리스트']
emails = []
for row in sheet.iter_rows(values_only=True):
emails.append(row[1]) # 이메일 주소가 있는 열의 인덱스에 따라 수정
# 이메일 전송
for receiver_email in emails:
message = MIMEMultipart()
message['From'] = email
message['To'] = receiver_email
message['Subject'] = "제목을 입력하세요"
body = "메일 본문을 입력하세요"
message.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(email, password)
text = message.as_string()
server.sendmail(email, receiver_email, text)
server.quit()
print("이메일이 성공적으로 보내졌습니다.")
