커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4주차 강의 질문
[왕초보] ChatGPT 300% 활용하기 v0
4주차
북마크
한*빈
댓글
1
추천
0
조회수
12
조회수
12
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


고객 파일을 받는것 까지 는 완성했는데,


import openpyxl

import smtplib

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart


# Gmail SMTP 서버 설정

smtp_server = 'smtp.gmail.com'

smtp_port = 587

smtp_username = 'test@gmail.com' #여러분들의 실사용 이메일 주소

smtp_password = "********" #생성한 앱 비밀번호


# 메일 제목, 본문 내용 등 설정

mail_subject = '메일 제목'

mail_body = '메일 본문 내용'


# Excel 파일에서 이름과 이메일 추출

wb = openpyxl.load_workbook('customer_data_test.xlsx')

ws = wb['test_name_email']


name_list = []

email_list = []


for row in ws.iter_rows(min_row=2, values_only=True):

name = row[0]

email = row[1]

name_list.append(name)

email_list.append(email)


# Gmail 서버 연결 및 메일 전송

with smtplib.SMTP(smtp_server, smtp_port) as smtp:

smtp.starttls()

smtp.login(smtp_username, smtp_password)


for name, email in zip(name_list, email_list):

# 메일 생성

message = MIMEMultipart()

message['From'] = smtp_username

message['To'] = email

message['Subject'] = mail_subject


# 메일 본문 추가

message.attach(MIMEText(mail_body))


# 메일 전송

smtp.send_message(message)


이 코드를 넣었더니 이런오류가 나왔어요.

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-3-15b1b5305051> in <cell line: 17>()
     15 
     16 # Excel 파일에서 이름과 이메일 추출
---> 17 wb = openpyxl.load_workbook('customer_data_test.xlsx')
     18 ws = wb['test_name_email']
     19 


3 frames

/usr/lib/python3.10/zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps)
   1249             while True:
   1250                 try:
-> 1251                     self.fp = io.open(file, filemode)
   1252                 except OSError:
   1253                     if filemode in modeDict:

FileNotFoundError: [Errno 2] No such file or directory: 'customer_data_test.xlsx'


엑셀 프로그램이 없이 넘버스로 파일을 열었었는데, 3주차4주차는 엑셀프로그램이 없으면 안되는 강의 같아요ㅜ

엑셀프로그램이없어서 메일이 안보내지는걸까요?



스파르타 즉문즉답







취소
 공유
취소
댓글 0
댓글 알림
나의얼굴