MBS NSWorkspaceMBS Question

This snippet of code works great to:

  1. launch mail.app
  2. open a new email
  3. then attach an image to it

My issue is that it only works once and if I try to press the button 2 and 3 times to repeat the code, it only just performs #1 (launches mail .app).
Has anyone seen this behavior?

Thanks in advance!

Dim ExportPic as New FolderItem
  ExportPic = SpecialFolder.Temporary.Child(ReportName)
  DevProfile_Onscreen_PagesArray(0).Save (ExportPic,Picture.SaveAsPNG)
  Call NSWorkspaceMBS.openFile(ExportPic,"Mail",true)

Mac OS 10.10.1
Xojo 2014R2.1
MBS Plugin 14.3

Why aren’t you using AppleScript?

I saw a post that showed this instead of Applescript and it was working well for that coder. I figured I would use it.


In my case I don’t need to fill out any to/from/subject/body etc. I just need to launch mail.app and attach an image to a new email for the user. MBS seems much easier since I haven’t worked much with Apple Scripts yet.

you ask Mail via NSWorkspace to open a file. No idea what it does.
Sorry, I may not be able to help here much.

[quote=157303:@Christian Schmitz]you ask Mail via NSWorkspace to open a file. No idea what it does.
Sorry, I may not be able to help here much.[/quote]
No, Christian you don’t understand the original post. I am not trying to open a file but open mail.app to attach an image. It works with the code I put above. It just won’t do this more than once.

I recall you may have to give the file a different name each time.

Thank you Sam! I will try that tonigbt. Have a great night/day :slight_smile:

Apple Script from a Sandboxed application is a mess at the moment. You’ll need to use NSAppleScript (MBS & my own Sandbox Kit have functions for this) to execute the Apple Script, then you must specify two entitlements (App Wrapper simplifies this process for you). However you will be initially rejected for having one of the entitlements, and at which point you need to argue that you need this entitlement. It can take weeks!

The other solution was to use NSSharingService, however thats no longer an option with 32-Bit apps on Yosemite. I have created a workaround for the sharing, however there are other issues that I’m addressing, and it actually seems like the whole stability of NSSharingService is poor in Yosemite. Sometimes it just never shows, even for apps like Safari.

Sam that was exactly it! My filename was the same every time and that was why it didn’t work. I change my filename every time someone presses that button and it works as expected. Thank you for solving this for me!

Mei Wenti - No worries :slight_smile:

Great you fixed it by changing filenames :slight_smile: