日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python - IBM Notes 发送邮件

發布時間:2023/12/29 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python - IBM Notes 发送邮件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

0. 環境說明

windows 10

Notes版本:9.0.1

原理是python調用win32 的com 組件發送郵件,所以和notes客戶端的版本有關系。

1. 安裝插件

用到Python庫 pywin32

pip install pywin32

2. 配置查找

服務器:

如圖下,比如SZdom/szABCtech, 腳本里面寫的時候為SZdom@szABCtech

郵件數據庫:

數據庫為:mail\你的郵件名

收件人:

User1/szABCtech

3. 代碼

#! python3 # _*_ coding:utf-8 _*_"""IBM notes send email Max.Bai """# notes 9.0 from win32com.client import DispatchEx from win32com.client import makepy makepy.GenerateFromTypeLibSpec('Lotus Domino Objects')# from win32com.client import DispatchEx # notes 8.5class NotesMail(object):def __init__(self, server, file):print('init mail client')self.session = DispatchEx('Notes.NotesSession')# self.server = self.session.GetEnvironmentString("MailServer", True)self.db = self.session.GetDatabase(server, file)if not self.db.IsOpen:print('open mail db')try:self.db.OPENMAILexcept Exception as e:print(str(e))print( 'could not open database: {}'.format(db_name) )# for notes 8.5 maybe# session = DispatchEx('Lotus.NotesSession')# session.Initialize(pwd)# self.db = session.getDatabase(server, file)# if not self.db.IsOpen:# try:# self.db.Open()# except pywintypes.com_error:# print( 'could not open database: {}'.format(db_name) )def send_mail(self, reciver_list, subject, body=None):doc = self.db.CREATEDOCUMENTdoc.sendto = reciver_listdoc.Subject = subjectif body:doc.Body = bodydoc.SEND(0, reciver_list)print('send success')def main():# recivers = ['User1/szABCtech', 'User2/szABCtech']recivers = ['User1/Szhittech']mail = NotesMail('dominoserver@szABCtech', 'mail\User1')mail.send_mail(recivers, 'test sender', 'This is a test mail body ')if __name__ == '__main__':main()

4. 參考鏈接

https://github.com/LeoLuo22/notesmail/blob/master/notesmail.py#L7

總結

以上是生活随笔為你收集整理的Python - IBM Notes 发送邮件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。