用pop3来接收邮件
具体发送的代码全是api函数,直接调用就行了
想加界面的话用c++的mfc或者调用api建窗口
百度搜都有的
BOOL exSetTestBands(LPBYTE lpLinear, short height, long stride){ //set gray and color bands to dib and buffer 0
int i, j, k
short bwid = 30
short offx, offy
//set bands
if (!lpLinear) return FALSE
for (i=0 i<height i++)
FillMemory(lpLinear+stride*i, stride, i)
offy = min(256, height/2)
for (i=offy i<height i++)
{
FillMemory(lpLinear+stride*i, stride/2, i-offy)
for (k=0, j=stride/2 j<stride j+=24, k+=18)
{
FillMemory(lpLinear+stride*i+j, 24, k)
}
}
offy = 0
//black
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0x0
}
offy = i
offx = 0
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0x0
}
}
//blue
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xff
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xff
}
}
//green
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xff00
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xff00
}
}
//cyan
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xffff
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xffff
}
}
//red
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xff0000
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xff0000
}
}
//magenta
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xff00ff
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xff00ff
}
}
//yellow
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xffff00
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xffff00
}
}
//white
for (i=offy i<offy+32 i++)
{
for (j=stride/2 j<stride j+=3)
*(DWORD *)(lpLinear+stride*i+j) = 0xffffff
}
offy = i
offx += bwid
for (i=0 i<min(256,height/2) i++)
{
for (j=offx j<offx+bwid j+=3)
{
*(DWORD *)(lpLinear+stride*i+j) = 0xffffff
}
}
//repeat
offx += bwid
while (stride/2>offx) //remain
{
for (i=0 i<min(256,height/2) i++)
{
memcpy(lpLinear+stride*i+offx, lpLinear+stride*i, stride/2-offx)
}
offx += bwid*8
}
return 1
}
BOOL exOutReport(HDC hPr, LPBITMAPINFOHEADER lpbi, LPSTR lpdib)
{
char szLine[1024]
char str[50]
int startx
SIZE sSize
RECT rect
HFONT hFont, hOldFont
int Horz, Vert
float XZoom, YZoom
TEXTMETRIC TextMetric /* information about character size */
Horz = GetDeviceCaps(hPr, HORZRES)
XZoom = (float)Horz/2400 //in standard of 300dpi for A4
Vert = GetDeviceCaps(hPr, VERTRES)
YZoom = (float)Vert/3300
rect.top = (int)(600*YZoom)
rect.bottom = (int)(2600*YZoom)
// Set hospital name
hFont = CreateFont((int)(90*YZoom), (int)(35*XZoom), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL)
hOldFont = (HFONT)SelectObject(hPr, hFont)
GetTextMetrics(hPr, &TextMetric)
Rectangle(hPr, (int)(100*XZoom), (int)(155*YZoom), (int)((Horz-100)*XZoom), (int)(156*YZoom)) //underline
strcpy(szLine, "中国医科院北京肿瘤医院")
GetTextExtentPoint32(hPr, szLine, strlen(szLine), &sSize)
startx = (Horz-sSize.cx)/2
TextOut(hPr, startx, (int)(50*YZoom), (LPSTR)szLine, strlen(szLine))
SelectObject(hPr, hOldFont)
DeleteObject(hFont)
// set date contents
hFont = CreateFont((int)(62*YZoom), (int)(22*XZoom), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL)
hOldFont = (HFONT)SelectObject(hPr, hFont)
//year-month-date
strcpy(szLine, "打印日期: ")
_strdate(str)
str[2] = 0
str[5] = 0
str[8] = 0
strcat(szLine, str+6)
strcat(szLine, "-")//"年")
strcat(szLine, str)
strcat(szLine, "-")//"月")
strcat(szLine, str+3)
//strcat(szLine,"日")
TextOut(hPr, (int)(1600*XZoom), (int)(200*YZoom), (LPSTR)szLine, strlen(szLine))
//delete font
SelectObject(hPr, hOldFont)
DeleteObject(hFont)
rect.right = (int)((float)lpbi->biWidth/lpbi->biHeight
*(rect.bottom-rect.top))
rect.left = (int)((Horz-rect.right)/2+100*XZoom)
rect.right += rect.left
if (rect.left < 0)
{
rect.left = (int)(100*XZoom)
rect.right = (int)(2200*XZoom)
rect.bottom = (int)((float)lpbi->biHeight/lpbi->biWidth
*(rect.right-rect.left))+rect.top
}
StretchDIBits (hPr, // DestDC
rect.left, // DestX
rect.top, // DestY
rect.right - rect.left, // DestWidth
rect.bottom - rect.top, // DestHeight
0, // SrcX
0, // SrcY
(int)lpbi->biWidth, // SrcWidth
(int)lpbi->biHeight, // SrcHeight
lpdib, // lpBits
(LPBITMAPINFO) lpbi, // lpBitInfo
DIB_RGB_COLORS, // wUsage
SRCCOPY) // dwROP
return 1
}
void COkMfcView::OnPrintpic()
{
// TODO: Add your command handler code here
//打印图像
CPrintDialog cpd = (FALSE, PD_ALLPAGES)
HDC hPr
CDC cdc
DOCINFO docinfo
cpd.DoModal()
hPr = cpd.GetPrinterDC()
if (!hPr) return
cdc.Attach(hPr)
docinfo.cbSize = sizeof(DOCINFO)
docinfo.lpszDocName = "prnfile"
docinfo.lpszOutput = NULL
docinfo.lpszDatatype = NULL
docinfo.fwType = 0
if (cdc.StartDoc(&docinfo) == -1) return
cdc.StartPage()
exOutReport(hPr, lpbi, lpdib)
cdc.EndPage()
cdc.EndDoc()
}
void COkMfcView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
RECT rcRect
POINT pt
int x,y
char szString[100]={0}
if (bActive)
return
rcRect.left=LOWORD(lScrnOffset)
rcRect.top=HIWORD(lScrnOffset)
rcRect.right=rcRect.left+lpbi->biWidth
rcRect.bottom=rcRect.top+lpbi->biHeight
MapWindowPoints((CWnd*)HWND_DESKTOP,(LPPOINT)&rcRect,2)
pt.x = point.x
pt.y = point.y
MapWindowPoints((CWnd*)HWND_DESKTOP,(LPPOINT)&pt,1)
x=pt.x-rcRect.left
y=pt.y-rcRect.top
if( (x>=0) && (x<lpbi->biWidth) && (y>=0) && (y<lpbi->biHeight) )
{
WORD gray
WORD r,g,b
LPBYTE lpPixel
long stride
long form,bufform
BYTE byBits
char szSource[32]
//1. screen
form=okSetCaptureParam(hBoard,CAPTURE_SCRRGBFORMAT,GETCURRPARAM) //-1
byBits=(BYTE)HIWORD(form)
if( okGetCaptureStatus(hBoard,0) ) { //capturing
lpPixel=(LPBYTE)okGetTargetInfo(hBoard, SCREEN, 0, NULL, NULL, &stride)
lpPixel+=pt.x*byBits/8+pt.y*stride
strcpy(szSource,"SCREEN")
}
else { //forzen
//wbytes=((((lpbi->biWidth*bits)+31)&~31)>>3)//bmp need 4 byte align
byBits=(BYTE)lpbi->biBitCount
stride=(lpbi->biWidth*byBits/8+3)/4*4 //dword align
lpPixel=(LPBYTE)lpdib+x*byBits/8+(lpbi->biHeight-y-1)*stride
strcpy(szSource,"DIB")
}
if(byBits<=8) { //8 bits
gray=*lpPixel
//gray=(BYTE)okReadPixel(hBoard,SCREEN,0,x,y-10)
//okWritePixel(hBoard,SCREEN,0,x,y-10,0x00ffff)
//sprintf(szString,"(%4i,%4i) = %s (%3i) ",pt.x-rcRect.left,pt.y-rcRect.top,szSource,gray)
}
else {
WORD wPixel
DWORD dwPixel
if(LOWORD(form)==FORM_RGB555) {
wPixel=((LPWORD)lpPixel)[0]
b= (wPixel&0x1f)<<3
g= ((wPixel>>5)&0x1f)<<3
r= ((wPixel>>10)&0x1f)<<3
}
else if(byBits==16) {
wPixel=((LPWORD)lpPixel)[0]
b= (wPixel&0x1f)<<3
g= ((wPixel>>5)&0x3f)<<2
r= ((wPixel>>11)&0x1f)<<3
}
else if(byBits>=24) {
dwPixel=((LPDWORD)lpPixel)[0]
//ShowCursor(0) //
//dwPixel=okReadPixel(hBoard,SCREEN,0,x,y) //$
//okWritePixel(hBoard,SCREEN,0,x,y,0x00ffff)//$
//ShowCursor(1)
b= (BYTE)(dwPixel&0xff)
g= (BYTE)(dwPixel>>8)&0xff
r= (BYTE)(dwPixel>>16)&0xff
}
sprintf(szString,"(%4i,%4i) = %s (%3i,%3i,%3i) ",pt.x-rcRect.left,pt.y-rcRect.top,
szSource,r,g,b)
}
//2. buffer
bufform=okSetCaptureParam(hBoard,CAPTURE_BUFRGBFORMAT,GETCURRPARAM) //-1
if( LOWORD(bufform)!= LOWORD(form) ) {
long dwPixel
dwPixel=okReadPixel(hBoard,BUFFER,-1,(short)x,(short)y) // read current frame
switch (LOWORD(bufform) ) {
case FORM_GRAY8:
case FORM_GRAY888:
case FORM_GRAY8888:
//dwPixel&=0xff
case FORM_GRAY10:
//dwPixel&=0x3ff
case FORM_GRAY12:
//dwPixel&=0xfff
case FORM_GRAY16: //gray
//dwPixel&=0xffff
sprintf(szString+strlen(szString)," BUFFER (%5i)",dwPixel)
break
//color
case FORM_RGB555:
b= (WORD)((dwPixel&0x1f)<<3)
g= (WORD)(((dwPixel>>5)&0x1f)<<3)
r= (WORD)(((dwPixel>>10)&0x1f)<<3)
sprintf(szString+strlen(szString)," BUFFER (%4i,%4i,%4i)",r,g,b)
break
case FORM_RGB888:
case FORM_RGB8888:
case FORM_RGB8886:
b= (WORD)(dwPixel&0xff)
g= (WORD)((dwPixel>>8)&0xff)
r= (WORD)((dwPixel>>16)&0xff)
if(LOWORD(bufform)==FORM_RGB8886) {
b=(b<<2) | (WORD)((dwPixel>>24)&0x3)
g=(g<<2) | (WORD)((dwPixel>>26)&0x3)
r=(r<<2) | (WORD)((dwPixel>>28)&0x3)
}
sprintf(szString+strlen(szString)," BUFFER (%4i,%4i,%4i)",r,g,b)
break
default:
//if(LOWORD(bufform)==FORM_RGB565) {
b= (WORD)((dwPixel&0x1f)<<3)
g= (WORD)(((dwPixel>>5)&0x3f)<<2)
r= (WORD)(((dwPixel>>11)&0x1f)<<3)
sprintf(szString+strlen(szString)," BUFFER (%4i,%4i,%4i)",r,g,b)
break
}
}
}
sBar->SetPaneText(0, szString)
return
}
void COkMfcView::OnSyshelp()
{
// TODO: Add your command handler code here
//系统帮助
::WinHelp(hWnd, "okHelp.hlp", HELP_HELPONHELP, 0)
}
void COkMfcView::OnCorr()
{
// TODO: Add your command handler code here
//相关内容
::WinHelp(hWnd, "okdemo.hlp", HELP_FINDER, 0)
}
3.70 icePub_receiveMaill 函数原型:
int WINAPI icePub_receiveMail(char *strUsername,char *strPassword,char *strSmtpSever,char *strMailText,int TextMaxLen,char *strFenge,char *strFilename,int deleteFlag)
输入:strUsername pop3用户名
strPassword 用户密码
strSmtpSever pop3服务器
TextMaxLen strMailText最大长度
StrFenge 每个邮件间分隔符串
DeleteFlag 收完是否删除邮标志
输出:strMailText 接收的邮件内容
StrFilename 附件文件列表,多个附件则分号分隔
VC sample 代码:
char buff[1024*30+1]
char strFileNameList[1024*10]
{
typedef int (WINAPI RECEIVEMAIL)( char *strUsername,char *strPassword,char *strSmtpSever,char *strMailText,int TextMaxLen,char *strFenge,char *strFilename,int deleteFlag)
RECEIVEMAIL *icePub_receiveMail = 0
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll")
if(hDLLDrv)
{
icePub_receiveMail = (RECEIVEMAILTEXT *)GetProcAddress(hDLLDrv, "icePub_receiveMail")
}
icePub_receiveMail("bigshuye","12345678","pop.tom.com",buff,1024*30,"\r\n\r\n",strFileNameList,0)
}
AfxMessageBox(buff)
http://dl.icese.net/dev.php?f=icePubDll.rar 下载
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)