News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Send a mail from application

Started by franlou, June 18, 2010, 10:49:44 AM

Previous topic - Next topic

franlou

Hello
I wish send a mail when I clic on a word which is in a text

how to make it?

Once I used this:

HyperLinkWndProc PROC uses ebx, hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL tmpFont  :LOGFONT
LOCAL rect:RECT
LOCAL pt:POINT
LOCAL ps:PAINTSTRUCT

    mov eax,uMsg
    .IF eax==WM_NCHITTEST
        mov eax, 1                                                  ;We want to handle the non client hit test so we return true or 1
        ret

   
  .....
    .ELSEIF eax==WM_LBUTTONDOWN                     ;le click du boutton est traité ici
          szText szHomepage, "mailto:dr.fl.menciere@orange.fr ?body=Numéro "
      szText Subject,"edit:pour voir"
      szText Blancp," : "
      invoke lstrcpy,ADDR buffer,ADDR szHomepage
      ;invoke lstrcat,ADDR buffer,ADDR Subject
      invoke lstrcat,ADDR buffer,ADDR App
    
      invoke lstrcat,ADDR buffer,ADDR Blancp
      invoke lstrcat,ADDR buffer,ADDR Nom
      ;invoke MessageBox, hDlg, ADDR buffer, ADDR App, MB_OK
      invoke ShellExecute,0,0,ADDR buffer,0,0,0

          ;PrintString buffer
                      invoke ShellExecute, NULL, NULL, offset buffer, NULL, NULL, SW_MAXIMIZE ;change this to represent your preset url

                      xor eax,eax

            ret
    .ENDIF

    invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam
    ret

HyperLinkWndProc endp

can you help me?
thanks

ragdog

#1
Hi

It gives many examples about it


DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if uMsg==WM_INITDIALOG
        invoke LoadCursor,NULL,IDC_ARROW
           mov hFinger,eax
        invoke GetDlgItem, hWnd,1001
          push eax
        invoke SetWindowLong, eax, GWL_WNDPROC, addr HyperLinkWndProc
           pop edx
        invoke SetWindowLong, edx, GWL_USERDATA, eax
           xor eax,eax 
           ret
    .elseif uMsg == WM_CTLCOLORSTATIC
            invoke SendMessage,lParam,uMsg,wParam,lParam


.data?
spoo        dd ?
hFinger     dd ?
.code
HyperLinkWndProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
LOCAL tmpFont  :LOGFONT 

.IF uMsg==WM_CTLCOLORSTATIC
    invoke SendMessage, hWnd, WM_GETFONT, 0, 0 
        mov spoo,eax
    invoke GetObject, spoo, sizeof LOGFONT, addr tmpFont ;
        mov tmpFont.lfUnderline, TRUE ;under line the link
    invoke CreateFontIndirect, addr tmpFont
    invoke SelectObject, wParam, eax
    invoke SetTextColor, wParam, Red ;change this to change the color of the link
    invoke GetSysColor, COLOR_MENU
    invoke SetBkColor, wParam, eax
    invoke GetStockObject, HOLLOW_BRUSH
        ret 
.ELSEIF uMsg==WM_NCHITTEST
    mov eax, 1 
        ret
.ELSEIF uMsg==WM_LBUTTONDOWN
    invoke ShellExecute, NULL, CTEXT ("open"), CTEXT ("mailto:YOURMAIL@gmx.com"), NULL, NULL, SW_SHOWNORMAL ;change this to represent your preset url
    xor eax,eax
        ret
.ELSEIF uMsg==WM_SETCURSOR
    invoke SetCursor,hFinger
    xor eax,eax
        ret
.ENDIF
    invoke GetWindowLong, hWnd, GWL_USERDATA 
    invoke CallWindowProc, eax, hWnd, uMsg, wParam, lParam 
        ret
    xor eax, eax
    ret
HyperLinkWndProc endp



Add in your resource a text with your email adress with ID 1001

This function Change this text color and make this as hyperlink for open the defualt windows email client.


franlou

Hi ragdog
I try your code but adapted to my program;
the function fails, the return value is an error value that is  equal to 31.
this is my code:


HyperLinkWndProc PROC  hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

LOCAL tmpFont  :LOGFONT
LOCAL rect:RECT
LOCAL pt:POINT
LOCAL ps:PAINTSTRUCT

    mov eax,uMsg
    .IF eax==WM_NCHITTEST
        mov eax, 1                                                  ;We want to handle the non client hit test so we return true or 1
        ret

    .ELSEIF eax == WM_CTLCOLORSTATIC
                invoke SendMessage, hWnd, WM_GETFONT, 0, 0
                mov edx,eax
                invoke GetObject, edx, sizeof LOGFONT, addr tmpFont
                mov tmpFont.lfUnderline, TRUE                       ;souligne le lien
                invoke CreateFontIndirect, addr tmpFont
               ; mov ebx,eax
                invoke SelectObject, wParam, eax

                .if hover == FALSE
                     invoke SetTextColor, wParam, Blue; change la couleur du lien;'Blue' est contenu dans window.inc
                .else
                     invoke SetTextColor, wParam,Yellow ;Red
                .endif

                invoke GetSysColor, COLOR_MENU
                invoke SetBkColor, wParam, eax
                invoke DeleteObject,ebx
                invoke GetStockObject, HOLLOW_BRUSH
                ret

    .ELSEIF eax==WM_MOUSEMOVE
        invoke GetParent,hWnd
        push ebx
        mov ebx,eax
        invoke GetActiveWindow
            .if eax == ebx
                invoke GetCursorPos,addr pt
                invoke GetWindowRect,hWnd,addr rect
                invoke PtInRect,addr rect,pt.x,pt.y
                .if eax
                    invoke GetCapture
                        .if !eax
                            invoke SetCapture,hWnd
                            mov hover,TRUE
                            invoke InvalidateRect,hWnd,FALSE,FALSE
                            invoke SetCursor,hFinger

                        .endif
                .else
                    invoke GetCapture

                        .if eax
                            invoke ReleaseCapture
                            mov hover,FALSE
                            invoke InvalidateRect,hWnd,FALSE,FALSE
                        .endif

                .endif
            .endif
            pop ebx
            xor eax,eax
            ret

    .ELSEIF eax==WM_LBUTTONDOWN     ;le click du boutton est traité ici au lieu de plus haut
          szText szHomepage, "mailto:dr.fl.menciere@orange.fr ?body=Numéro de série de "
      szText Subject,"edit:Enregistrement"
      szText Blancp," : "
                szText ouvert,"open"; 19/6/2010

      invoke lstrcpy,ADDR buffer,ADDR szHomepage    ;buffer:"mailto:dr.fl.menciere@orange.fr ?body=Numéro de série de "

;      ;invoke lstrcat,ADDR buffer,ADDR Subject
;      invoke lstrcat,ADDR buffer,ADDR AppName
;     ;invoke lstrcat,ADDR buffer,ADDR CrLf
;      invoke lstrcat,ADDR buffer,ADDR Blancp
;      invoke lstrcat,ADDR buffer,ADDR UserName
      invoke MessageBox, hWnd, ADDR buffer, ADDR AppName, MB_OK    ;!!!  18/6/2010
      invoke ShellExecute,NULL,ADDR ouvert,ADDR buffer,0,0, SW_SHOWNORMAL;SW_MAXIMIZE ;

PrintString buffer
PrintHex eax
PrintDec eax

            ;invoke GetWindowText,hWnd,offset buffer,sizeof buffer       ;change this for using a preset url
;PrintString buffer
           ; invoke ShellExecute, NULL, offset szOpen, offset buffer, NULL, NULL, SW_MAXIMIZE ;change this to represent your preset url
            ;invoke ShellExecute, NULL, NULL, offset buffer, NULL, NULL, SW_MAXIMIZE ;change this to represent your preset url

            mov hover,FALSE
            invoke InvalidateRect,hWnd,FALSE,FALSE

            invoke SendMessage, hWnd, WM_GETFONT, 0, 0                  ;Get the defualt system font
            mov edx,eax                                             ;store result
            invoke GetObject, edx, sizeof LOGFONT, addr tmpFont ;get our font into a logfont structure
            mov tmpFont.lfUnderline, TRUE                   ;under line the link
            invoke CreateFontIndirect, addr tmpFont     ;Create the new font
            mov ebx,eax                             ;We need the return to free the memory later
            invoke SelectObject, wParam, ebx        ;Select our control
            invoke SetTextColor, wParam, Blue          ;change this to change the color of the link


            xor eax,eax

            ret
    .ENDIF
;
    invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam


    ret

HyperLinkWndProc endp

ragdog

Hey

What is your goal?

This example hyperlink a text in a editbox and change this color
Click you this Hyperlink open the windows default mail client

I understand not correct what you try?

franlou

My goal is to send a mail to somebody (ex: "francois@wanadoo.fr") with a subject(ex: "enregistrement") and a body (ex: "numero xxxx" )  when I click on a hyperlink which is in a dialogbox like an AboutDialog

Here is my proceeding:
;£££££££££££££££
OpenDialog proc
;££££££££££££££
invoke DialogBoxParam, hInstance, ADDR DlgEnregistrement,hMainWnd,ADDR EnrProc,NULL
ret
OpenDialog endp

;£££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££
;                   Handle the Enr Dialog Message
;£££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££
EnrProc proc stdcall   , hDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;IDC_URL equ   4003
       mov   eax, uMsg
.IF (eax == WM_INITDIALOG)
            invoke GetDlgItem, hDlg,IDC_Nom; met le focus sur le nom
       invoke SetFocus,eax
        ;--------------------------------
            invoke GetDlgItem, hDlg, IDC_URL  ;=> boutton traité ds HyperLinkWndProc = 4003           
            invoke SetWindowLong, eax, GWL_WNDPROC, ADDR HyperLinkWndProc
            mov orgStatic,eax
           
            invoke LoadCursor,hInstance,ID_DOIGTCURSOR
            mov hFinger,eax
            xor eax,eax
            ret
.ELSEIF eax == WM_CTLCOLORSTATIC
            invoke SendMessage,lParam,uMsg,wParam,lParam
            ret
;----------------------------------
.ELSEIF (eax == WM_COMMAND)
       mov eax,wParam
       .IF  ax==IDOK;ID_OK;
             .......
        .ENDIF
         ......
.ELSE
   mov   eax, FALSE   ; show message not processed
   jmp   Return
.ENDIF
   mov   eax, TRUE   ; show message was processed
Return:   ret
EnrProc   ENDP
;£££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££££
HyperLinkWndProc PROC uses ebx esi edi, hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LOCAL tmpFont  :LOGFONT
LOCAL rect:RECT
LOCAL pt:POINT
LOCAL ps:PAINTSTRUCT

    mov eax,uMsg
    .IF eax==WM_NCHITTEST
        mov eax, 1             ;We want to handle the non client hit test so we return true or 1
        ret

    .ELSEIF eax == WM_CTLCOLORSTATIC
                invoke SendMessage, hWnd, WM_GETFONT, 0, 0
                mov edx,eax
                invoke GetObject, edx, sizeof LOGFONT, addr tmpFont
                mov tmpFont.lfUnderline, TRUE              ;souligne le lien
                invoke CreateFontIndirect, addr tmpFont
                invoke SelectObject, wParam, eax
                .if hover == FALSE
                     invoke SetTextColor, wParam, Blue
                .else
                     invoke SetTextColor, wParam,Red
                .endif

                invoke GetSysColor, COLOR_MENU
                invoke SetBkColor, wParam, eax
                invoke DeleteObject,ebx
                invoke GetStockObject, HOLLOW_BRUSH
                ret 0
    .ELSEIF eax==WM_MOUSEMOVE
        invoke GetParent,hWnd
        push ebx
        mov ebx,eax
        invoke GetActiveWindow
            .if eax == ebx
                invoke GetCursorPos,addr pt
                invoke GetWindowRect,hWnd,addr rect
                invoke PtInRect,addr rect,pt.x,pt.y
                .if eax
                    invoke GetCapture
                        .if !eax
                            invoke SetCapture,hWnd
                            mov hover,TRUE
                            invoke InvalidateRect,hWnd,FALSE,FALSE
                            invoke SetCursor,hFinger
                        .endif
                .else
                    invoke GetCapture
                        .if eax
                            invoke ReleaseCapture
                            mov hover,FALSE
                            invoke InvalidateRect,hWnd,FALSE,FALSE
                        .endif
                .endif
            .endif
            pop ebx
           ; xor eax,eax
            ret 0
    .ELSEIF eax==WM_LBUTTONDOWN     
          szText szHomepage, "mailto:francois@wanadoo.fr?body=Numéro "
      szText Subject,"edit:Enregistrement"
      szText Blancp," : "
                szText ouvert,"open"; 19/6/2010
      invoke lstrcpy,ADDR buffer,ADDR szHomepage
      invoke lstrcat,ADDR buffer,ADDR Subject
   
      invoke ShellExecute,NULL,ADDR ouvert,ADDR buffer,0,0, SW_SHOWNORMAL

PrintString buffer<<<<<<<<<<<It's OK
PrintDec eax<<<<<<<<<<<<<<<<< = 31   ??????

            mov hover,FALSE
            invoke InvalidateRect,hWnd,FALSE,FALSE
            invoke SendMessage, hWnd, WM_GETFONT, 0, 0              ;Get the defualt system font
            mov edx,eax                                             ;store result
            invoke GetObject, edx, sizeof LOGFONT, addr tmpFont ;get our font into a logfont structure
            mov tmpFont.lfUnderline, TRUE                   ;under line the link
            invoke CreateFontIndirect, addr tmpFont         ;Create the new font
            mov ebx,eax                             ;We need the return to free the memory later
            invoke SelectObject, wParam, ebx        ;Select our control
            invoke SetTextColor, wParam, Blue          ;change this to change the color of the link
            xor eax,eax
            ret
    .ENDIF
    invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam
    ret
HyperLinkWndProc endp

ragdog

Hi

Ok I think it gives masm32 examples here on board
i have only a goasm example you can convert it to masm32 ,this is very easy


cmp eax,HLINK_EMAIL
jne >>B2
invoke GetWindowLong,[hlc_hWin],36
mov ebx,eax
invoke lstrlen,ebx
jnz >
xor ebx,ebx
:
invoke lstrcpy,[hlc_pSubject],OFFSET hlc_szMailTo
mov eax,[hlc_pSubject]
add eax,7
or ebx,ebx
jz >
invoke lstrcpy,eax,ebx
jmp >B0
:
invoke GetWindowText,[hlc_hWin],eax,240
B0:
invoke GetWindowLong,[hlc_hWin],24
or eax,eax
jz >>B2
push eax
invoke lstrcat,[hlc_pSubject],OFFSET hlc_szSubject
pop eax
mov D[hlc_strlen],2048
invoke lstrcat,[hlc_pSubject],eax
invoke GetWindowLong,[hlc_hWin],28
or eax,eax
jz >B2
push eax
invoke lstrcat,[hlc_pSubject],OFFSET hlc_szBody
pop eax
invoke lstrcat,[hlc_pSubject],eax
B2:
invoke FormatURL,[hlc_pSubject],OFFSET hlc_text,TRUE
invoke ShellExecute, [hlc_hWin], OFFSET hlc_szOpen,OFFSET hlc_text, 0, 0, SW_SHOWNORMAL
jmp >>.DONE


http://www.quickersoft.com/donkey/files/Hyperlink.zip

clive

Personally I'd just use SMTP, and there is always MAPI.
It could be a random act of randomness. Those happen a lot as well.

Gunner

I agree with clive, just use SMTP... Google RFC 2821
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

jj2007

#9
Hey, why do I get the impression that you are trying hard to make franlou's life difficult...?
:bg

ragdog

What is this for a file type asc?

Gunner

jj, doesn't work here.... I don't have a default mail app installed..  if the OP uses SMTP or MAPI that wouldn't matter  :wink
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

jj2007

Quote from: ragdog on June 20, 2010, 06:13:30 PM
What is this for a file type asc?

Assembler Source Code aka RTF. I added the plain text version above.

jj2007

Quote from: Gunner on June 20, 2010, 07:15:35 PM
jj, doesn't work here.... I don't have a default mail app installed..  if the OP uses SMTP or MAPI that wouldn't matter  :wink

I don't think an ordinary user
a) has no default mail app installed,
b) would appreciate if a little proggie sends mail on its own,
therefore I would rather not recommend SMTP or MAPI.

P1

With the advances in SPAM control on email servers(i.e. reverse lookups), Firewalls(that will only let the mail server send mail, because of black listing services due internal SMTP viruses), writing an email sending routine is pretty much pointless.

I did, but the email never left the LAN.  I got an email for error reporting on my software.

Maybe if you would advise us of the purpose/use and we can recommend a better solution.  i.e.  Is this for copy control ???

Plus, you have an assumption that the user is going to have Internet access that is not controlled or limited.  Not always true, not good for support for you.

Regards,  P1   :8)