PowerBASIC Peer Support Forums
 

Go Back   PowerBASIC Peer Support Forums > User to user Discussions > PowerBASIC Console Compiler

Notices

PowerBASIC Console Compiler User to user discussions about the PowerBASIC Console Compiler product line.

Reply
 
Thread Tools Display Modes
  #1  
Old Sep 29th, 2003, 08:02 AM
Bill Scharf Bill Scharf is offline
Member
 
Join Date: Aug 2003
Posts: 93
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
Reply With Quote
  #2  
Old Sep 29th, 2003, 11:24 AM
Kev Peel Kev Peel is offline
Member
 
Join Date: Sep 2000
Location: South West, United Kingdom
Posts: 2,858
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).]
Reply With Quote
  #3  
Old Sep 29th, 2003, 01:38 PM
Matthew Berg Matthew Berg is offline
Member
 
Join Date: May 1999
Posts: 797
See also MS KB article Q197782.

------------------
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.
Reply With Quote
  #4  
Old Sep 30th, 2003, 10:28 AM
Mark Hunter Mark Hunter is offline
Member
 
Join Date: Feb 2001
Posts: 1,463
When
"the default mail client is not properly installed"
how does the program tell?
__________________
DownsizeDC.org
Reply With Quote
  #5  
Old Sep 30th, 2003, 01:31 PM
Matthew Berg Matthew Berg is offline
Member
 
Join Date: May 1999
Posts: 797
Quote:
When
"the default mail client is not properly installed"
how does the program tell?
How does what program tell what?

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.
Reply With Quote
  #6  
Old Sep 30th, 2003, 10:13 PM
Mark Hunter Mark Hunter is offline
Member
 
Join Date: Feb 2001
Posts: 1,463
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
Reply With Quote
  #7  
Old Oct 1st, 2003, 06:14 AM
Bill Scharf Bill Scharf is offline
Member
 
Join Date: Aug 2003
Posts: 93
Quote:
Originally posted by Mark Hunter:
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.
Ok, this makes sense...anybody know how to check this in the PowerBasic Console? Is it the same for win 95a through XP, or does it differ?

------------------
Bill Scharf
Drake Software
"We're Serious About Tax Software"
__________________
Bill Scharf
Reply With Quote
  #8  
Old Oct 1st, 2003, 06:57 AM
Kev Peel Kev Peel is offline
Member
 
Join Date: Sep 2000
Location: South West, United Kingdom
Posts: 2,858
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
Reply With Quote
  #9  
Old Oct 2nd, 2003, 05:49 AM
Charles Kincaid Charles Kincaid is offline
Member
 
Join Date: May 1999
Posts: 51
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.)
Reply With Quote
  #10  
Old Oct 2nd, 2003, 08:44 AM
Dean Schrage Dean Schrage is offline
Member
 
Join Date: Apr 2003
Posts: 348
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
Reply With Quote
  #11  
Old Oct 2nd, 2003, 09:37 AM
Kev Peel Kev Peel is offline
Member
 
Join Date: Sep 2000
Location: South West, United Kingdom
Posts: 2,858
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
The email program must support HTML format editing (like Outlook Express).

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
Reply With Quote
  #12  
Old Oct 2nd, 2003, 06:50 PM
Steve Matthews Steve Matthews is offline
Member
 
Join Date: May 2001
Location: Alameda, CA, US
Posts: 312
Quote:
Originally posted by Dean Schrage:
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.
Use %0a in the text to generate line feeds

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
That's been in production for several years, I'm pretty sure it works...
Reply With Quote
  #13  
Old Oct 3rd, 2003, 05:24 AM
Dean Schrage Dean Schrage is offline
Member
 
Join Date: Apr 2003
Posts: 348
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
Reply With Quote
  #14  
Old Oct 3rd, 2003, 08:09 AM
Steve Matthews Steve Matthews is offline
Member
 
Join Date: May 2001
Location: Alameda, CA, US
Posts: 312
Quote:
Originally posted by Dean Schrage:
... I can only deposit a certain size string after which the email program
Outlook in this case, will no longer come to activation ... if the string is too big, it just won't work.
Also how might one attach a text file instead.
The first problem is really a command line capacity problem. I can't remember exactly the max length, off-hand seems something like 512k. Don't know a way around that.

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.
Reply With Quote
  #15  
Old Oct 3rd, 2003, 11:39 AM
Dean Schrage Dean Schrage is offline
Member
 
Join Date: Apr 2003
Posts: 348
ok thanks for helping

regards

Dean

------------------
__________________


TITAN Algorithms
Dedicated to the development of advanced computational software solutions
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright © 1999-2010 PowerBASIC, Inc. All Rights Reserved.
Error in my_thread_global_end(): 1 threads didn't exit