Add Attachment Outlook 2016

I’m trying to add an attachment wich is inside my script folder, I just can’t get it to work properly.

Why…

set MyPath to (path to me) as string

import my script when adding (file:MyPath) as an attachment in Outlook.

but…

set MyPath2 to (MyPath & "Contents:Ressources:OVERPRINT PREVIEW.pdf")

doesn’t import anything when adding (file:MyPath2) as an attachment in Outlook.

I want to import the file (OVERPRINT PREVIEW.pdf) as attachment in Outlook.

I don’t have Outlook, so test yourself:


set aliasPath to path to me
set aliasPath to ((aliasPath as string) & "Contents:Ressources:OVERPRINT PREVIEW.pdf") as alias
tell application "System Events" to set posixPath to (POSIX path of aliasPath)
set theFile to POSIX file posixPath

tell application "Microsoft Outlook" to set newMessage to make new outgoing message
tell newMessage to make new attachment with properties {file: theFile}

it replies that error message…

File Macintosh HD:Users:me:Downloads:EmailApprob:Email_Approb.app:Contents:Ressources:OVERPRINT PREVIEW.pdf wasn’t found.

and the “as alias” is highlighted after the error

set aliasPath to ((aliasPath as string) & "Contents:Ressources:OVERPRINT PREVIEW.pdf") as alias

It’s Resources with one s, not two.

Ouch!!! :o

Thank you! Feel a bit dumb :smiley:

You avoid the whole problem if you use this:

path to resource "OVERPRINT PREVIEW.pdf"

Thanks a lot, I’ll use it in the future