国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python使用兩種發郵件的方式smtp和outlook示例

2020-01-04 17:16:07
字體:
來源:轉載
供稿:網友

smtp是直接調用163郵箱的smtp服務器,需要在163郵箱中設置一下。outlook發送就是Python直接調用win32方式。調用程序outlook直接發送郵件。

import win32com.client as win32 import xlrd outlook = win32.Dispatch('outlook.application') mail = outlook.CreateItem(0) receivers = ['Yutao.A.Wang@alcatel-sbell.com.cn'] mail.To = receivers[0] mail.Subject ='test1' workbook = xlrd.open_workbook('E://kpi excel//00_summary.xls') mySheet = workbook.sheet_by_index(0)  nrows = mySheet.nrows content = [] for i in range(nrows):  ss = mySheet.row_values(i)  content.append(ss)  print(content)  Truecontent =str(content)  mail.Body = Truecontent mail.Attachments.Add('E://kpi excel//00_summary.xls') mail.Send() 

smtp發送郵件

import smtplib from email.mime.text import MIMEText mail_host = 'smtp.163.com' mail_user = '18298268658' mail_pass = 'cat123' sender = '18298268658@163.com' receivers = ['619538553@qq.com']  message = MIMEText('content','plain','utf-8') message['Subject'] = 'title' message['From'] = sender message['To'] = receivers[0]  try:  smtpObj = smtplib.SMTP()  smtpObj.connect(mail_host,25)  smtpObj.login(mail_user,mail_pass)  smtpObj.sendmail(   sender,receivers,message.as_string())  smtpObj.quit()  print('success') except smtplib.SMTPException as e:  print('error',e) 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荥阳市| 方城县| 永嘉县| 昂仁县| 平南县| 巴楚县| 钟山县| 胶州市| 乌拉特前旗| 咸宁市| 龙南县| 罗定市| 阿拉尔市| 宜兰县| 沅江市| 师宗县| 家居| 青冈县| 宣武区| 华阴市| 渭源县| 嘉黎县| 顺义区| 淮阳县| 清水河县| 达尔| 双辽市| 湟中县| 宝丰县| 读书| 杨浦区| 当涂县| 郸城县| 平乐县| 汕尾市| 班玛县| 日照市| 夏邑县| 兴隆县| 长顺县| 郎溪县|