I am trying to code an Apple Script App in Xcode for sending automated e-mails.
I need to add multiple images to email body. Since the app will be used by multiple users, I also need to add images with relative links.
However, I am not sure how to do this. Is it possible to call images from Xcode assets? or is there any other easier way to do this?
Thank you all in advance?
Model: MBP M1 Pro 2021
AppleScript: XCode 14 - Apple Script template is taken from Xcode 13
Browser: Safari 605.1.15
Operating System: macOS 13
Thank you so much for your response.
The source you provided suggests:
let image = NSImage(named: “ImageName”)
So if I have three images to add, should I use
let imageA = NSImage(named: “Image-Top”)
let imageB = NSImage(named: “Image-Middle”)
let imageC = NSImage(named: “Image-Bottom”)
then call variables imageA, imageB, and imageC later in e-mail body?
Not exatly… that is Swift programming language…
You need ASObjC and that is AppleScript + Objective-C
Something like this…
set theImage to current application’s NSImage’s imageNamed:“YOUR_IMAGE_NAME”
NSImage is class and imageName is type method. In AppleScript you use current application to call class name. You could find many examples for NSImage class in this forum.
Yes it’s important when your reading any developer documentation to
Make sure it’s in showing Objective-C code.
“Let” is a Swift command.
Somehow Xcode 14 does not allow me to assign actions to “sender”
Thus, I decided to create a simple Automator script.
However, I could not figure out how to assign an online image source (the image file is located in a shared cloud storage folder) to a variable.
Any help much appreciated.