python怎么实现新建一个notes邮箱,同时将excel中的数据拷贝到邮件中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python怎么实现新建一个notes邮箱,同时将excel中的数据拷贝到邮件中相关的知识,希望对你有一定的参考价值。

参考技术A from win32com.client import Dispatch

def SendEmail(SendTo, CC, BCC, Subject, Body, Attachment=None, Pass=None):

if SendTo==None:
return

session=Dispatch("Lotus.NotesSession")

if Pass:
session.Initialize(Pass)

Server=session.GetEnvironmentString( "MailServer",True)
MaildbName=session.GetEnvironmentString( "MailFile",True)
db=session.GetDatabase(Server,MaildbName)
doc=db.CreateDocument()
doc.ReplaceItemValue("Form","Memo")

if SendTo:
doc.ReplaceItemValue("SendTo",SendTo)

if CC:
doc.ReplaceItemValue("CopyTo",SendTo)

if BCC:
doc.ReplaceItemValue("BlindCopyTo",SendTo)

if Subject:
doc.ReplaceItemValue("Subject",Subject)

stream=session.CreateStream()
stream.WriteText(Body)

bodyMime=doc.CreateMIMEEntity()
bodyMime.SetContentFromText(stream,"text/html;charset=iso-8859-1",False)

if Attachment:
RichTextItem = doc.CreateRichTextItem("Attachment")

for fn in Attachment:
RichTextItem.EmbedObject(1454, "", fn ,"Attachment")

'''
bodyMime=doc.CreateMIMEEntity()
bodyMime.SetContentFromText(stream,"text/html;charset=iso-8859-1",False)
doc.ReplaceItemValue( "Logo", "StdNotesLtr3" )
doc.ReplaceItemValue( "_ViewIcon", 23 )
doc.ReplaceItemValue( "SenderTag", "Y" )

'''
doc.Send(False)

SendEmail("yourname@yourdomain",None,None,"Title:test for python","body:test for python send mail",
["d:/testtool/teri/pcsim/test.xls","d:/testtool/teri/pcsim/test_email.py"],"password")


可以看下这段代码,电脑没有notes邮箱,未测试

PS:需要下载对应版本的pywin32


代码出处:http://blog.csdn.net/matlab2000/article/details/5945363

[Python Study Notes]物体运动检测

基于opencv的cv2模块实现

\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
>>文件: iot_client.py
>>作者: liu yang
>>邮箱: liuyang0001@outlook.com
>>博客: www.cnblogs.com/liu66blog
>>博客: liuyang1.club (抱歉,域名备案中,稍后恢复访问)

\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cv2
import numpy as np
import easygui
import datetime
from twilio.rest import Client

# 打开摄像头
camera= cv2.VideoCapture(0)
# 如果摄像头打开失败
if camera.isOpened() == False:
    # 给与友好性提示
    easygui.msgbox("\\n\\n\\n\\n\\n\\n                 请保证摄像头可以正常被打开,请检查硬件后重新运行",title=\'提示框\',ok_button=\'确定\')
# 得到摄像头的图像尺寸
size = (int(camera.get(cv2.CAP_PROP_FRAME_WIDTH)),
        int(camera.get(cv2.CAP_PROP_FRAME_HEIGHT)))
# 打印尺寸
print(\'size:\'+repr(size))
es = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5,4))
kernel = np.ones((5,5),np.uint8)
background = None
flag = 0
while True:
    # 有没有检测到的文本
    text = "Undetected"
    # 读取摄像头的参数
    grabbed , frame_lwpCV=camera.read()
    try:
        # 将图像转换为RGB
        gray_lwpCV = cv2.cvtColor(frame_lwpCV,cv2.COLOR_RGB2GRAY)
        # 将图像进行高斯滤波,去除噪点
        gray_lwpCV = cv2.GaussianBlur(gray_lwpCV,(25,25),3)
    except cv2.error:
        break

    # 判断是否有标准的背景图,如果没有就将上面摄像头采集的第一帧的图像作为背景图
    if background is None:
        background = gray_lwpCV
        continue
    # 将两个图像进行比较
    diff = cv2.absdiff(background,gray_lwpCV)
    diff = cv2.threshold(diff,50,255,cv2.THRESH_BINARY)[1]
    # 进行3次膨胀
    diff = cv2.dilate(diff,es,iterations=3)

    # 忽略掉一些很小的因素
    image , contours , hierarchy = cv2.findContours(diff.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    for c in contours:
        # 如果变化的狂过小,则忽略
        if cv2.contourArea(c) < 2000:
            continue
        (x, y, w, h) = cv2.boundingRect(c)
        cv2.rectangle(frame_lwpCV, (x, y), (x + w, y + h), (0, 255, 0), 2)
        # 有物体闯入到背景中,以文本标记
        text = "Detected"

    # 如果文本标记为无
    if text == "Undetected" :
        # 在图像上标出
        cv2.putText(frame_lwpCV,"Motion: {}".format(text),(10,20),
                           cv2.FONT_HERSHEY_SIMPLEX,0.5,(0,255,0),2)
        # 放置时间戳
        cv2.putText(frame_lwpCV,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        (10,frame_lwpCV.shape[0]-10),cv2.FONT_HERSHEY_SIMPLEX,0.35,(0,255,0),2)

    # 如果检测到
    if text == "Detected" :
        cv2.putText(frame_lwpCV,"Motion: {}".format(text),(10,20),
                           cv2.FONT_HERSHEY_SIMPLEX,0.5,(0,0,255),2)
        cv2.putText(frame_lwpCV,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        (10,frame_lwpCV.shape[0]-10),cv2.FONT_HERSHEY_SIMPLEX,0.35,(0,255,0),2)
        # 蒋告警标志位置为1
        flag=1

    # 判断告警标志位
    if flag == 1:
        # 接入一些接口,进行对用户的警示,微信,丁丁,短信 ...等等
        # 然后将标志位置为0
        pass

    # 显示图像
    cv2.imshow(\'contours\',frame_lwpCV)
    # 灰度图像的显示
    # cv2.imshow(\'dis\',diff)

    # 添加退出键--q
    # 按下退出本次监测
    key = cv2.waitKey(1) & 0xff
    if key == ord(\'q\'):
        break

# 退出后释放摄像头
camera.release()
cv2.destroyAllWindows()


# 声明:该代码源于腾讯课堂-动脑学院-Python公开课,并加以适当修改

以上是关于python怎么实现新建一个notes邮箱,同时将excel中的数据拷贝到邮件中的主要内容,如果未能解决你的问题,请参考以下文章

note3电子邮件里怎么设置不了qq邮箱

[Python Study Notes]实现对鼠标控制

[Python Study Notes]实现对键盘控制与监控

python note

[Python Study Notes]物体运动检测

[Python Study Notes]批量将wold转换为pdf