![]() |
|
|||||||
| PowerBASIC Console Compiler User to user discussions about the PowerBASIC Console Compiler product line. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
PB/CC: Launch new email screen-don't send it
I have found how to send an email, but we want to launch the "default mail program" and have the user type the body of the email.
We want to auto-fill the recipient's address. This would be similar to an html mailto link. Any suggestions? Thanks in Advance! ------------------ Bill Scharf Drake Software "We're Serious About Tax Software"
__________________
Bill Scharf |
|
#2
|
|||
|
|||
|
Try this...
Code:
#Include "WIN32API.INC" Function PBMain ShellExecute 0, "open", "mailto:youraddress@email.com?subject=Subject Line&body=The Message Typed Here...", "", "", %SW_SHOW End Function Kev Peel http://www.kgpsoftware.com [This message has been edited by Kev Peel (edited September 29, 2003).] |
|
#4
|
|||
|
|||
|
When
"the default mail client is not properly installed" how does the program tell?
__________________
DownsizeDC.org |
|
#5
|
|||
|
|||
|
Quote:
If you want the mechanisms mentioned above to work, you make to make sure a default mail client has been specified. This is done via the Programs tab on the Internet Options applet in Control Panel. ------------------ If you try to make something idiot-proof, someone will invent a better idiot.
__________________
If you try to make something idiot-proof, someone will invent a better idiot. |
|
#6
|
|||
|
|||
|
If the user had no default mail program, when he runs Kev's
program he will get an error message from Windows. Better the program -- Kev's -- checked that the default mail was setup properly before trying to access it, and deal with any problem instead of Windows.
__________________
DownsizeDC.org |
|
#7
|
|||
|
|||
|
Quote:
------------------ Bill Scharf Drake Software "We're Serious About Tax Software"
__________________
Bill Scharf |
|
#8
|
|||
|
|||
|
This simple piece of code will allow you to look up the default client
in the registry. If the mail program is found, then it is run. Code:
'______________________________________________________________________________
'
' Program to get the default e-mail client program
'
'
' By KGP Software, 25th July 2001.
' Updated and Tested on: WinME and XP Pro 1st Oct 2003.
'______________________________________________________________________________
#Compile Exe
#Dim All
#Register All
#Include "win32api.inc"
%BUFFER_LEN = 1024
'------------------------------------------------------------------------------
' Registry encapsulation function
'------------------------------------------------------------------------------
Function GetReg(ByVal iLocation As Long, ByVal sSubKeys As String, _
ByVal sValueName As String, ByVal sDefault As String) As String
Local hKey As Dword, zRegVal As Asciiz * %BUFFER_LEN
If iLocation = 0 Then iLocation = %HKEY_CURRENT_USER
If RegOpenKeyEx(iLocation, Trim$(sSubKeys, "\"), 0, %KEY_READ, hKey) = %ERROR_SUCCESS Then
If RegQueryValueEx(hKey, ByCopy sValueName, 0, %REG_SZ, zRegVal, %BUFFER_LEN) _
<> %ERROR_SUCCESS Then GoTo RegStringDefault:
Else
RegStringDefault:
zRegVal = sDefault
End If
If hKey Then RegCloseKey hKey
Function = zRegVal
End Function
'------------------------------------------------------------------------------
' Program Start Point
'------------------------------------------------------------------------------
Function PBMain As Long
Local sName As String, zTmp As Asciiz * %BUFFER_LEN, zMailClient As Asciiz * %BUFFER_LEN
' Get mail name...
sName = GetReg(%HKEY_LOCAL_MACHINE, "SOFTWARE\Clients\Mail", "", "")
' Get mail program name...
zTmp = GetReg(%HKEY_LOCAL_MACHINE, "SOFTWARE\Clients\Mail\" + sName + "\shell\open\command", "", "")
' Must expand environment strings like %ProgramFiles% (if any)
ExpandEnvironmentStrings zTmp, zMailClient, SizeOf(zMailClient)
' If in quotes, then get whats inside the quotes...
If InStr(zMailClient, Chr$(34)) Then zMailClient = Parse$(zMailClient, Chr$(34), 2)
If zMailClient = "" Then
' Can't find it...
MessageBox 0, "Couldn't find the default mail client", "MainClientFinder", %MB_ICONHAND
Else
' Ask to execute mail client
If MessageBox(0, "Default mail client: " + zMailClient + $CrLf + $CrLf + "Run the default mail client now?", _
"MainClientFinder", %MB_ICONQUESTION Or %MB_YESNO) = %IDYES Then
ShellExecute 0, "open", zMailClient, "", "", %SW_SHOW
End If
End If
End Function
Kev Peel http://www.kgpsoftware.com |
|
#9
|
|||
|
|||
|
I just tested this on 2000 Pro and it works fine.
I incorporated the line from Kev Peel and it worked. Sort of... I use PocoMail for my client. It launchs if needed (I keep it open most of the day) goes into a new message and puts in the address and subject perfectly. The body text shows up under my signature. This, though, is a PocoMail issue and not a PB one. My only question is what about multiple users on same machine? Cool code BTW. ------------------ ATB Charles Kincaid (The above is my opinion alone and not that of either my employer or clients.)
__________________
ATB Charles Kincaid (The above is my opinion alone and not that of either my employer or clients.) |
|
#10
|
|||
|
|||
|
in this example is there any way to get the email body to register
$CRLF like this: body=" + S_Line_1 + $CRLF + S_Line_2 I have tried this but the CRLF are just stripped out. thanks regards Dean Code:
ShellExecute 0, "open", "mailto:youraddress@email.com?subject=Subject Line&body=" + S_Line_1 + $CRLF + S_Line_2, "", "", %SW_SHOW ------------------
__________________
TITAN Algorithms Dedicated to the development of advanced computational software solutions |
|
#11
|
|||
|
|||
|
Specify HTML tags to get formatting, like...
Code:
ShellExecute 0, "open", "mailto:youraddress@email.com?subject=Subject Line&body=<html>line1<br>line2</html>", "", "", %SW_SHOW I don't know about multiple users. You'd probably have to find the correct registry keys for that. Regmon ( http://www.sysinternals.com/ntw2k/source/regmon.shtml ) may help. Regards, ------------------ Kev Peel http://www.kgpsoftware.com |
|
#12
|
|||
|
|||
|
Quote:
Here's a sample: Code:
s$ = "mailto:support@xyz.com?subject=XYZ%20Debug%20Information" s$ = s$ & "&body=Dear%20User%20-%20Please%20ATTACH%20ALL%20*.TXT%20FILES%20in%20%20" & s1$ 's1$ contains a directory name s$ = s$ & ",%20fill%20in%20below%20and%20send%0a%0a" '%0a's are line feeds s$ = s$ & "Name/Company:%0aAddress/City/State:%0aPhone%20%26%20Email:%0a" s$ = s$ & "Windows%20Version:%0a" s$ = s$ & "Problem%20Description:%0a%0a%0a%0adebug%20" & BuildDebugString() 'where BuildDebugString creats some application-specific text diagnostics |
|
#13
|
|||
|
|||
|
Steve your example solves a problem but reveals another. It appears
that I can only deposit a certain size string after which the email program Outlook in this case, will no longer come to activation. That is if the string is too big, it just won't work. I have confirmed this with testing. How can this be solved? Also how might one attach a text file instead. this would also solve the problem. Thanks for your assistance. regards Dean ------------------
__________________
TITAN Algorithms Dedicated to the development of advanced computational software solutions |
|
#14
|
|||
|
|||
|
Quote:
I did a lot of research back then and never found a way to attach a file using this method of invocation. Bottom line is that this facility is of limited use. |
|
#15
|
|||
|
|||
|
ok thanks for helping
regards Dean ------------------
__________________
TITAN Algorithms Dedicated to the development of advanced computational software solutions |
![]() |
| Thread Tools | |
| Display Modes | |
|
|