News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

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 needing to a best method  :( :( :(
please checking these 2 site for fixing it
http://www.sitepoint.com/forums/showthread.php?150784-Preventing-Hotmail-from-blocking-CDONTS-CDOSYS-mail
http://www.experts-exchange.com/Database/MS_Access/Q_27808811.html



TouEnMasm

Fa is a musical note to play with CL

hamidfarhadiyan2

QuoteI 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, sending to smtp in silent

TouEnMasm

This one do it without problem.Need to add an attachment,that all.
http://masm32.com/board/index.php?topic=3034.msg31642#msg31642

You need to save screen in a file and add an attachment to the email,like that
Quote
Sending a text email with an attached file.
By repeating the .AddAttachment method you can attach more than one file.
When attaching files keep in mind that your recipient may be limited in their
ability to receive files above a certain size. Many ISPs limit emails to 8 or 10MB each.
You should not send large files to anyone before obtaining their permission.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"
objMessage.Send

The objMessage refers to IMessage AddAttachment

just modify the sfile path
Quote
CUNI (sfile,"E:\cdo\editmasm.ini",0)


Fa is a musical note to play with CL

TouEnMasm

Fa is a musical note to play with CL

TWell

That HotMail issue is not solved yet ?

Big thank's to ToutEnMasm for pointing some nasty things :t

PS:
I removed my old examples, but new test version for Gmail users are in old place Reply #7
Now without any macros or include files.

Vortex

Hi ToutEnMasm,

Here is the Gmail script :


Set objEmail = CreateObject("CDO.Message") 
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objEmail.Configuration.Fields.Update
objEmail.From = "username@gmail.com" 
objEmail.To = "destination@domain.com" 
objEmail.Subject = "Test" 
objEmail.Textbody = "This is a test." 
objEmail.AddAttachment "C:\Documents and Settings\Vortex\Desktop\sample.txt"
objEmail.Send
set objEmail = Nothing


The trick is to specify the field sendusername without the domain name gmail.com

Vortex

Saving the desktop as .bmp file with OLE image functions :


; Tiny tool to save the desktop image to a BMP file
; Usage : SaveDesktop bitmapname.bmp

.386
.model flat,stdcall
option casemap:none

include SaveDesktop.inc

.data
IID_IPicture  GUID <7BF80980h,0BF32h,101Ah,<8Bh,0BBh,00h,0AAh,00h,30h,0Ch,0ABh>>

.data?
buffer        db 512 dup(?)

.code

start:

    call    main
    invoke  ExitProcess,0

main PROC uses esi

LOCAL pBitmap   :DWORD
LOCAL hGlobal   :DWORD
LOCAL pStream   :DWORD
LOCAL pcbSize   :DWORD
LOCAL hBmp      :DWORD
LOCAL hDC       :DWORD
LOCAL tempDC    :DWORD
LOCAL x         :DWORD
LOCAL y         :DWORD
LOCAL hOldBmp   :DWORD
LOCAL pd        :PICTDESC
LOCAL bm        :BITMAP

    lea     esi,[buffer]
    invoke  ParseCmdLine,esi
    cmp     eax,2
    je      @f
    ret
@@:
    invoke  GetDC,0                                 ; get the DC of desktop
    mov     hDC,eax
    invoke  CreateCompatibleDC,eax                  ; create a DC compatible with hDC
    mov     tempDC,eax
    invoke  GetSystemMetrics,SM_CXSCREEN            ; get the width and height of the screen
    mov     x,eax
    invoke  GetSystemMetrics,SM_CYSCREEN
    mov     y,eax
    invoke  CreateCompatibleBitmap,hDC,x,eax        ; create a compatible bitmap
    mov     hBmp,eax
    invoke  SelectObject,tempDC,eax
    mov     hOldBmp,eax
    invoke  BitBlt,tempDC,0,0,x,y,hDC,0,0,SRCCOPY   ; copy the screen to the target DC
    invoke  SelectObject,tempDC,hOldBmp             ; return back the old handle
    mov     pd.cbSizeofstruct,SIZEOF PICTDESC       ; initialize the PICTDESC structure
    mov     pd.picType,PICTYPE_BITMAP
    push    hBmp
    pop     pd.bmp.hbitmap
    mov     pd.bmp.hpal,0
    lea     edx,[pBitmap]
    invoke  OleCreatePictureIndirect,ADDR pd,ADDR IID_IPicture,TRUE,edx
                                                    ; create the OLE image
    invoke  CreateStreamOnHGlobal,NULL,TRUE,ADDR pStream
                                                    ; create the destination stream to save the image
    lea     eax,[pcbSize]
    push    eax
    push    TRUE
    push    pStream
    mov     eax,pBitmap
    push    eax
    mov     eax,DWORD PTR [eax]
    call    IPicture.SaveAsFile[eax]                ; save the image to the stream
    invoke  GetHGlobalFromStream,pStream,ADDR hGlobal
    invoke  GlobalLock,hGlobal                      ; get the address pointing the image in memory
    invoke  WriteFileToDisc,DWORD PTR [esi+4],eax,pcbSize
                                                    ; write the image to disc
    mov     eax,pBitmap                             ; release pBitmap
    push    eax
    mov     eax,DWORD PTR [eax]
    call    IPicture.Release[eax]

    mov     eax,pStream
    push    eax
    mov     eax,DWORD PTR [eax]
    call    IStream.Release[eax]                    ; release the stream and hGlobal

    invoke  DeleteObject,hBmp                       ; return back resources to the OS
    invoke  DeleteDC,tempDC
    invoke  ReleaseDC,0,hDC
    ret
   
main ENDP

END start

hamidfarhadiyan2

Thanks of all user that gives to me help
getting screenshots issue is completed and it is finished now

I just want adding to it a script that it sending screenshots to hotmail-smtp
Gmail-smtp is block in my country, and "HotMail issue is not solved yet"

TWell


TouEnMasm


To hamidfarhadiyan2,
Give us the two emails you want to use,there is no reason for they don't work in your country.
Fa is a musical note to play with CL

Vortex

SendEmail :

QuoteSendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to learn and use.
SendEmail is licensed under the GNU GPL, either version 2 of the License or (at your option) any later version.
[Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]

It works on Windows 7

http://caspian.dotconf.net/menu/Software/SendEmail/