Email - Send Using Default Client

Category: Internet

Date: 02-16-2022

Return to Index


 
'This code uses the default email client - it send message information
'to the client, which opens but does not automatically send.  You can edit
'the content and then press Send within the client
 
'Primary Code
Local EMessage as AscIIZ*%Max_Path
EMessage$ = "mailto:[email protected]?subject=gbSnippets&body=Comments:"
iReturn& = ShellExecute(hDlg, "Open", EMessage$ , $Nul$Nul, %SW_ShowNormal)
 
'To insert an email address as a variable, use something like this:
temp$ = "[email protected]"
EMessage$ = "mailto:" + temp$ + "?subject=gbSnippets&body=Comments:"
 
'Each component in EMessage$ is separated by the ampersand (&) sign. Only the
'first component after the initial email address has a question mark (?) preceding
'the ampersand. Email clients vary on what they will recognize with mailto: but
'here are common options:
 
    'mailto:[email protected]
    '[email protected]
    '[email protected]
    '&subject=Shipping%20Information%20Request
    '&body=Please%20tell%20me%20if%20my%20order%20has%20shipped!">Shipping Request</a>
 
'Usually, if an email client simply ignores components it doesn't recognize.
'If you need parentheses in the text, use Chr$(34)
 
'Any $crlf in the body of the message must be replaced with "%OD%0A"
Replace $CrLf With "%0D%0AIn temp$
 
 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg as Dword
%IDC_Button = 100
 
Function PBMain() As Long
   Dialog New Pixels, 0, "Email Test",300,300,200,200, %WS_OverlappedWindow To hDlg
   Control Add Button, hDlg, %IDC_Button,"Send", 50,10,100,20
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   If CB.Msg = %WM_Command AND CB.Ctl = %IDC_Button AND CB.Ctlmsg = %BN_Clicked Then
      Local EMessage as AsciiZ * %Max_Path, iReturn&
      EMessage$ = "mailto:[email protected]?subject=gbSnippets&body=Comments:"
      iReturn& = ShellExecute(hDlg, "Open", EMessage$ , $Nul$Nul, %SW_ShowNormal)
   End If
End Function
 
'gbs_00185
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm