Hello, I would like to open a picture file with mail, to be an attachment. Used to work in the old days. Example below opens the png file in Preview. Suggestions to open it with Mail?
Manual says: FolderItem.Open (parameters As String = “”, activate As Boolean = True) parameters is the app’s parameters to be passed to the app being open.
it opens the app for file with this extension
so if folderitem is a .pdf it opens a registered pdf viewer
if folderitem is a .html it open the default browser.
somehow you open a picture and give the paint app the fApp path.
this open Mozilla Thunderbird Mailer with Text File as Attachment
Var a As FolderItem = New FolderItem("C:\Program Files\Mozilla Thunderbird\thunderbird.exe",FolderItem.PathModes.Native)
a.Open(Encodings.UTF8.Chr(34)+"C:\Users\Markus\Desktop\Neues Textdokument.txt"+Encodings.UTF8.Chr(34))
i used “” around because space in path. without “” the space would be a argument separator.
your problem is the mixed up fDoc & fApp
u will open the app with the pic as argument.
i think fDoc.Open(fApp.NativePath,True)
should be fApp.Open(fDoc.NativePath,True)
In theory and according to Xojo’s Documentation this should work (assuming the .app you’re launching is accepting a parameter, which is a shell path to a file that it’s going to open):
fApp.Open(fDoc.ShellPath, True)
If that doesn’t work, another option would be to use a Shell(same assumption as above regarding parameters):
Dim s As New Shell
s.Execute("open -n " + fApp.ShellPath + " " + fDoc.ShellPath)
Having said that, just another thing to keep in mind:
That most likely won’t work on the latest macOS Versions. System Applications are located in a different folder/volume. You shouldn’t try to locate an .app like this, but ask the OS where to find the app with a specific BundleID (in your example this would be: com.apple.mail).
Here is an example project that shows how to find an .app by BundleID, list all possible “Application Directories”, list all applications that can deal with a given file: App Directories example
just opens Preview.app (which is asking for a file to be opened) when built with Xojo 2021r2.1
Makes me think that the revamped FolderItem(Xojo 2019r2: FolderItem updated to use latest OS APIs on macOS) is still not working as expected for this situation
If so… then Shell should be an alternative.