Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Dec 14, 2018 2:34 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Email Client Question
PostPosted: Wed Jan 16, 2013 7:49 pm 
Offline

Joined: Mon Dec 12, 2011 7:25 pm
Posts: 186
Location: Grand Rapids MI Area
I have searched for an answer to this but did not find one other than someone's plugin.

Is there a way to find out the name of the default Email Client on a mac ?

Is it Apple Mail or FireFox or whatever ?

_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Mountain Lion 10.8.3 and Windows 7
Toshiba Laptop Running Windows 7, WinXP SP3 and Windows 8
REAL Studio Enterprise Edition 2012r2.1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 5:51 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Run this command in a Shell :)
VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'

It should return the name of the users default e-mail client!

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 11:39 am 
Offline

Joined: Mon Dec 12, 2011 7:25 pm
Posts: 186
Location: Grand Rapids MI Area
@Akiland

I tried to use your command but all I can get is a syntax error.
What am I not doing right ?

Dim s As New Shell
Dim cmd As String
#If TargetMacOS Then
cmd = "VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'"
#Endif
s.Execute(cmd)
If s.ErrorCode=0 Then
MsgBox s.Result
Else
MsgBox "Error " + Str(s.ErrorCode)
End If

_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Mountain Lion 10.8.3 and Windows 7
Toshiba Laptop Running Windows 7, WinXP SP3 and Windows 8
REAL Studio Enterprise Edition 2012r2.1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 12:37 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
I guess you'll need double double-quotes around "mailto" like this:
""mailto""

Try that :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 12:39 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Hmm, I see now that this does not seem to work on my computer here at home with Mountain Lion...worked at my computer at work that runs Lion.
Sorry it does not seem to be so "universal" :/

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 12:44 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Found an Apple-Script that might work better :)
set prefPath to (path to preferences as text) & "com.apple.LaunchServices.plist"
tell application "System Events"
try
value of property list item "LSHandlerRoleAll" of (first property list item of property list item "LSHandlers" of property list file prefPath whose value of property list items contains "mailto")
on error
"com.apple.mail"
end try
end tell

It doesn't return the "name" exactly but almost..
Mail.app returns "com.appel.mail"
If I change my default client to Sparrow it returns "com.sparrowmailapp.sparrow"

U can use "OSASCRIPT "in a shell to run an apple-script.
Could this work for you? :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 12:56 pm 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
I remember having probems in the past, it seemed to me that there are different locations (I believe Apple may have moved it around in different versions of OSX :roll: ).

This is the applescript I used in one of my programs to determine the default email program by name, hopefully something here might be of help:

GetDefaultMailAppInfo()

to GetDefaultMailAppInfo()
try
set p to POSIX path of (path to preferences) & "com.apple.LaunchServices.plist"
tell application "System Events" to tell property list item "LSHandlerRoleAll" of (property list item 1 ¬
of property list item "LSHandlers" of property list file p whose value contains "mailto") to if exists then
set v to value
tell application "Finder" to set {name:n, name extension:e} to application file id v
tell (count e) + 1 to return n's text 1 thru -(1 mod it + it)
end if
--"Mail"
on error
try
set creatorType to word -1 of (do shell script "defaults read com.apple.LaunchServices |grep -C5 U:mailto | grep -w LSBundleSignature")
set {text:creatorType} to (text of creatorType) as text
tell application "Finder"
set {defEmailName, emailContainerAlias} to {name, container} of application file id creatorType
end tell
return defEmailName
on error
try
set y to do shell script "defaults read com.apple.LaunchServices | sed -n '/mailto;/{s/.*\\.\\(.*\\)\".*/\\1/p;}' "
return y
on error
return ""
end try
end try
end try
end GetDefaultMailAppInfo


This worked for my situation, although it seemed that in most cases, the preference didn't get set until the default email program was switched from Mail to another application, then back to 'Mail'.

_________________
RB 2009r4 Windows XP


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 1:32 pm 
Offline

Joined: Mon Dec 12, 2011 7:25 pm
Posts: 186
Location: Grand Rapids MI Area
@markwalsh

I just tried putting the double quotes around the mailto and it worked on my Mac OS X Lion 10.7.3

Problem is I'll never know the system the end user will be using my program in though.
It is for Mac & Windows

What I am having problems with is sending some text to an email client.
I have sent the subject line and body text to apple mail and Thunderbird and the format is different
for both. If I create a string for apple mail it works ok but it becomes one full line in Thunderbird
and if I get it right for Thunderbird it becomes one line in apple mail so what I was trying to do is
check what email client they were using and send the correct string to the email client.

I have not been able to get one string to work correctly on both.

In body text one will look like: Line 1
Line 2
Line 3 and so on

but the other email client will look like: Line1 Line 2 Line 3 and so on

_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Mountain Lion 10.8.3 and Windows 7
Toshiba Laptop Running Windows 7, WinXP SP3 and Windows 8
REAL Studio Enterprise Edition 2012r2.1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 2:01 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Did you try a simple mailto using showURL()?
I have only tried with Mail.app and Sparrow since it's the only ones i have but they work fine :)
ShowURL("mailto:me@mydomain.com?subject=my%20subject&body=body%20of%20email")

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 2:55 pm 
Offline

Joined: Mon Dec 12, 2011 7:25 pm
Posts: 186
Location: Grand Rapids MI Area
@Akiland

Yes I did and it works ok in apple mail but not Thunderbird.
This is the string I used:

Dim message1 As String
Message1 = "Thought you might want this campground information." + EndOfLine + EndOfLine +_
CampgroundNameText.Text + EndOfLine +_
AddressText.Text + EndOfLine +_
CityText.Text + ", " + StatePopup.Text + ", " + PostalCodeText.Text + EndOfLine + EndOfLine +_
"Latitude N: " + LatitudeNText.Text + EndOfLine +_
"Longitude W: " + LongitudeWText.Text + EndOfLine + EndOfLine +_
"Phone: " + PhoneText.Text + " Toll Free: " + TollFreeText.Text + EndOfLine + EndOfLine +_
"Email: " + EmailText.Text + EndOfLine +_
"Website: "+ WebsiteText.Text + EndOfLine + EndOfLine +_
"Season Opens: " + CampgroundOpensText.Text + EndOfLine +_
"Season Closes: " + CampgroundClosesText.Text + EndOfLine + EndOfLine

ShowURL("mailto:me@mydomain.com?subject=my%20subject&body=" + message1)


In apple mail I get What is expected:
Quote:
Thought you might want this campground information.

The Ultimate Campground Log
1244 Lake St
Lake City, MI, 12345-6789

Latitude N: 42.123.5678
Longitude W: -82.123.5678

Phone: (111) 222-3333 Toll Free: (800) 222-3333

Email: jerry@theultimatecampgroundlog.com
Website: http://www.theultimatecampgroundlog.com

Season Opens: 04/01
Season Closes: 10/31


And in Thunderbird I get what was not expected:
Quote:
Thought you might want this campground information. The Ultimate Campground Log 1244 Lake St Lake City, MI, 12345-6789 Latitude N: 42.123.5678 Longitude W: -82.123.5678 Phone: (111) 222-3333 Toll Free: (800) 222-3333 Email: jerry@theultimatecampgroundlog.com Website: http://www.theultimatecampgroundlog.com Season Opens: 04/01 Season Closes: 10/31


Any Ideas ?

_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Mountain Lion 10.8.3 and Windows 7
Toshiba Laptop Running Windows 7, WinXP SP3 and Windows 8
REAL Studio Enterprise Edition 2012r2.1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac


Top
 Profile  
Reply with quote  
 Post subject: Re: Email Client Question
PostPosted: Thu Jan 17, 2013 2:59 pm 
Offline

Joined: Mon Dec 12, 2011 7:25 pm
Posts: 186
Location: Grand Rapids MI Area
Now if I do it this way it works in Thunderbird but not in apple mail

ShowURL "mailto:" + mailName + "?&Subject=" + vsubject +_
"&body=" + "Thought you might want this campground information." + EndOfLine +_
"&body=" + "" +_
"&body=" + CampgroundNameText.Text +_
"&body=" + AddressText.Text +_
"&body=" + Address1Text.Text +_
"&body=" + CityText.Text + ", " + StatePopup.Text + ", " + PostalCodeText.Text +_
"&body=" + "" +_
"&body=" + "Latitude N: " + LatitudeNText.Text +_
"&body=" + "Longitude W: " + LongitudeWText.Text +_
"&body=" + "" +_
"&body=" + " Phone: " + PhoneText.Text +_
"&body=" + "Toll Free: " + TollFreeText.Text +_
"&body=" + "" +_
"&body=" + "Email: " + EmailText.Text +_
"&body=" + "Website: "+ WebsiteText.Text +_
"&body=" + "" +_
"&body=" + "Season Opens: " + CampgroundOpensText.Text +_
"&body=" + "Season Closes: " + CampgroundClosesText.Text

_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Mountain Lion 10.8.3 and Windows 7
Toshiba Laptop Running Windows 7, WinXP SP3 and Windows 8
REAL Studio Enterprise Edition 2012r2.1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group