News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Send a file to SMTP using masm32/Please help me

Started by hamidfarhadiyan2, March 17, 2014, 02:28:49 AM

Previous topic - Next topic

hamidfarhadiyan2

I created a masm-software for capturing screenshots, It's completed
Now I want  adding to it a feature for attaching "screenshots captured" and after attaching, they sending to smtp/ftp in silent

After my try, I can't finding a code for add "send to smtp"
Please help me

TouEnMasm


Found in a french site (don't read the comments)
Fa is a musical note to play with CL


TouEnMasm

This file doesn't exist
You must put in comment those lines.
Quote
;INVOKE   GetPassword   ;Decoder le mot de passe
;INVOKE   KillPassword
It is in case you want to encrypt your password.
You have also to modify:
Quote
INVOKE   InternetConnect,hInternet,ADDR ServeurFtp,21,ADDR UserName, ADDR Password,1,0,0   ;Se connecte au serveur
ServeurFtp is your ftp provider without ftp://
UserName is your full mail adresse
password is the mail adresse password
FileLocal is the directory where to put the downloaded file
FileServer is the name of the file you want to download





Fa is a musical note to play with CL

TouEnMasm


I have put some comments in english.
Test on my site

;LogFTP.exe - Freeware by Bluebibubble - www.rph-concept.com
;
;------------------------------------------------------------------------------------------------
include sdk32.inc
include wininet.sdk
includelib Wininet.lib


.DATA

AppName DB 'Log File Transfert',0
NullString DB 0
;------------------------- MODIFY Those three lines ---------------------------------------------
ServeurFtp DB 'perso-ftp.orange.fr',0
Password db 'Wrong',0
UserName DB 'wrong@orange.fr',0
;-------------------------------------------------------------------------------------
MsgErreur DB "Une erreur est survenue, le fichier log n'à pas été transferé !",0
FileServer DB "index.html",0 ;The file to load

;------------ five lines NOT MOVABLE ----------------------------------------------
FileLocal DB 'E:\envoi_file_ftp\' ;Modify this directory
FileYear DD 0
FileMonth DW 0
FileDay DW 0
FileExt DB '.LOG',0    ;end of the new named file


CnvBuff DW 0,0
fMtStrinG DB "%lu",0

.DATA?

hInternet DD ?
hConnection DD ?
hFind DD ?

DirInfo WIN32_FIND_DATA <?>
DateBuffer SYSTEMTIME <?>

.CODE

Start: INVOKE InternetOpen,ADDR AppName,1,ADDR NullString,ADDR NullString,0 ;Ouvre une connection
.if eax == 0 ;internet
jmp GetError
.else
mov hInternet,eax
.endif

;Password and Username are NULL, the function uses the default "anonymous" password.
INVOKE InternetConnect,hInternet,ADDR ServeurFtp,21,ADDR UserName, ADDR Password,1,0,0 ;Se connecte au serveur
.if eax == 0 ;internet
jmp GetError
.else
mov hConnection,eax
.endif


INVOKE FtpFindFirstFile,hConnection,ADDR FileServer,ADDR DirInfo,0,0 ;Vérifie présence du
.if eax == 0 ;internet
jmp GetError
.endif
lea edx,DirInfo.cFileName
lea ecx,DirInfo.cAlternateFileName

INVOKE FileTimeToSystemTime,ADDR DirInfo.ftLastWriteTime,ADDR DateBuffer ;Convertir la date en
xor eax,eax ;en Nom de fichier
mov ax,DateBuffer.wYear
INVOKE  wsprintf,ADDR FileYear,ADDR fMtStrinG,eax
xor eax,eax
mov ax,DateBuffer.wMonth
INVOKE  wsprintf,ADDR CnvBuff,ADDR fMtStrinG,eax
mov ax,CnvBuff
cmp ah,0
jnz @F
ror ax,8
mov al,'0'
@@: mov FileMonth,ax
xor eax,eax
mov ax,DateBuffer.wDay
INVOKE  wsprintf,ADDR CnvBuff,ADDR fMtStrinG,eax
mov ax,CnvBuff
cmp ah,0
jnz @F
ror ax,8
mov al,'0'
@@: mov FileDay,ax
xor eax,eax

INVOKE FtpGetFile,hConnection,ADDR FileServer,ADDR FileLocal,\ ;Transfert le fichier
0,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0
or eax,eax
jz GetError
close:
INVOKE InternetCloseHandle,hConnection ;Referme les connections
INVOKE InternetCloseHandle,hInternet ;et
      INVOKE ExitProcess,0 ;quitte sans erreur
     
GetError: INVOKE  MessageBox,0,ADDR MsgErreur,ADDR AppName,MB_OK ;Si on arrive ici, il
      INVOKE ExitProcess,1;y a eu une erreur.

END Start

Fa is a musical note to play with CL

Vortex

SMTP Client :

http://www.codeproject.com/Articles/28806/SMTP-Client

TWell

#6
CDOSYS ?

TWell

#7
Simple example with cdosys.
Change options in CDOSendTest.asm like smtpserver, sender, receiver, ...
How to make it better?

EDIT 2014-03-21:
- fix some bugs. CDOSendTest_a2.zip UNICODE version.
- no macros or headers used anymore.

hamidfarhadiyan2

Thank you for all help
Last help is good,
I changed smtpserver, sender, receiver, ... in file (CDOSendTest.asm)
But I'm after run have a error to name: 80040213

I thinking it need to password also
how to adding password or fixing error ?



TWell

These fields are needed:
;hr = SetItem(pFlds, L"http://schemas.microsoft.com/cdo/configuration/smtpserverport", NULL, 465);
;hr = SetItem(pFlds, L"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", NULL, 1);
;hr = SetItem(pFlds, L"http://schemas.microsoft.com/cdo/configuration/smtpusessl", NULL, 1);
;hr = SetItem(pFlds, L"http://schemas.microsoft.com/cdo/configuration/sendusername", pUser, 0);
;hr = SetItem(pFlds, L"http://schemas.microsoft.com/cdo/configuration/sendpassword", pPWord, 0);

hamidfarhadiyan2

Codes should be add in what file ?
Please config like with this smtp :
SMTP Server :
smtp.live.com
port : 587
User : hamidfarhadiyan@outlook.com
Pass : 359416

hamidfarhadiyan2

Quote from: hamidfarhadiyan2 on March 20, 2014, 02:54:56 AM
Codes should be add in what file ?
Please config like with this smtp :
SMTP Server :
smtp.live.com
port : 587
User : hamidfarhadiyan@outlook.com
Pass : 359416


hamidfarhadiyan2

Codes should be add in what file ?
Please config like with this smtp :
SMTP Server :
smtp.live.com
port : 587
User : hamidfarhadiyan@outlook.com
Pass : 359416

[/quote]
[/quote]

TWell

Alternate version in original message.
Added user, pass, port too.

hamidfarhadiyan2

user, pass, port are changed
But again after run I have a error : 80040211
Why?
Please checking and fixing it