python代码
# -*- coding: utf-8 -*-
import sys
import smtplib
import mimetypes
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
def AutoSendMail( fn ):
msg = MIMEMultipart()
msg['From'] = "XXXX.XXX.com"
msg['To'] = "XXXX.XXX.com"
msg['Subject'] = "Send Email Test"
file1 = fn
image = MIMEImage(open(file1,'rb').read())
image.add_header('Content-ID','<image1>')
msg.attach(image)
server = smtplib.SMTP()
server.connect('smtp.163.com')
server.login('youremailaccount@XXX.com','your smtp passwd')
server.sendmail(msg['From'],msg['To'],msg.as_string())
server.quit()
if __name__ == "__main__":
if (len( sys.argv ) < 2):
print( "too fewer input arguments" )
else:
print(sys.argv[1])
try:
AutoSendMail( sys.argv[1] )
except Exception,e:
print( Exception, ": ", e, "!!!!" )
C++代码
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "cv.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
/** @function main */
int main( int argc, char** argv )
{
string code("python ../email/sendPic.py ");
string name = "../img/1.bmp";
code = code + name;
cout << "begin to send email!!" << endl;
system( code.c_str() );
cout << "end~~" << endl;
//waitKey(0);
return(0);
}
注:里面有些关于opencv的头文件可以去掉,同时,程序里合成的发送邮件的字符串,在自己点电脑上测试时,要注意文件路径并修改字符串
- 第一个参数是python
- 第二个参数是python文件所在的路径
- 第三个参数是图片所在的路径
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
PROJECT (cppTest)
find_package(OpenCV REQUIRED)
ADD_EXECUTABLE(vizTest vizTest)
target_link_libraries(vizTest ${OpenCV_LIBS})
话说之前的乱七八糟的又点多,不知道有没有删错。。这个要是不行的话,从网上重新查找一个CMakeList.txt就行。