from openpyxl import load_workbook
wb = load_workbook("邮件地址.xlsx")
ws = wb.active
address = {}
for i in range(2,ws.max_row+1):
dept = ws["A"+ str(i)].value
to_add = ws["B"+ str(i)].value
cc_add = ws["C"+ str(i)].value
address[dept] = [to_add,cc_add]
import win32com.client as win32
def Send_mail(to_add, cc_add,file_path,dept):
'''
传入参数说明:
to_add,收件人地址
cc_add,抄送地址
file_path,附件路径
dept,部门名称
'''
outlook = win32.Dispatch('Outlook.Application') # 调用windows outlook应用
mail = outlook.CreateItem(0) # 创建邮件
mail.to = to_add #收件人
mail.cc = cc_add #抄送人
mail.Subject = "{}年假情况".format(dept) #主题
mail.Attachments.Add(file_path) #添加附件。若有多个附件,则多调用几次即可
mail.Body = '''Dear All,\n这是{}的年假情况,请查收!谢谢。\n\nBest regards!\n人事部 小李'''.format(dept)#正文内容
mail.Send() #发送邮件
#发送邮件到各部门
for dept in address.keys():
to_add = address[dept][0]
cc_add = address[dept][1]
file_path = os.getcwd() + '\\年假_按部门\\年假情况_{}.xlsx'.format(dept)
Send_mail(to_add, cc_add,file_path,dept)
print("邮件发送完成。")
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Python学习:实战代码Demo案例集 解锁Python编程新境界,从实战出发,直击技术核心。本资源精心汇集了一系列Python实战代码Demo案例,不仅涵盖基础语法到高级特性的全面应用,更深度融合前端HTML技术,展现Web开发的无限可能。 通过亲手实践这些案例,您将掌握如何利用Python构建动态网页、处理用户输入、实现前后端数据交互等关键技能。HTML技术的巧妙融入,让您的Python项目在视觉与功能上均达到专业水准,无论是构建个人博客、企业官网还是电商平台,都能游刃有余。 每个案例均附详细代码注释与实现思路,即便是编程新手也能快速上手,逐步成长为Python与前端开发的复合型人才。立即探索,让代码成为您创造精彩网页的魔法钥匙!
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 16 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/196b0ad537b04e688a2a9ae3fce83c0a_black_cat7.jpg!1)
DTcode7
- 粉丝: 2w+
- 资源: 4986
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)