如何将图片分配给Applescript中的新Outlook联系人? Outlook字典告诉我Outlook确实有一个图像类,但我不知道如何填充一个。它似乎不喜欢只是被赋予finder认为是Jpeg文件的东西:
tell application "Finder"
set theImageFile to a reference to file "Macintosh HD:Users:maximiliantyrtania:Pictures:image-151718-galleryV9-zhek.jpg"
--set theImageFilePosixPath to POSIX file "/Users/maximiliantyrtania/Pictures/image-151718-galleryV9-zhek.jpg"
set filekind to (kind of theImageFile) as string
display dialog "its a" & filekind--displays "its a jpeg"
end tell
tell application "Microsoft Outlook"
make new contact with properties {first name:"some", last name:"one", image:theImageFile, email addresses:{{address:"work@mywork.com", type:work}, {address:"home@myhome.com", type:home}}}
end tell
结果:error "„«class docf» \"image-151718-galleryV9-zhek.jpg\" of «class cfol» \"Pictures\" of «class cfol» \"maximiliantyrtania\" of «class cfol» \"Users\" of «class sdsk» of application \"Finder\"“ kann nicht in den erwarteten Typ umgewandelt werden." number -1700 from «class docf» "image-151718-galleryV9-zhek.jpg" of «class cfol» "Pictures" of «class cfol» "maximiliantyrtania" of «class cfol» "Users" of «class sdsk»
我想我必须说出以下内容: 设置imageToAssign以创建新的image(),但语法可能是什么?在网上找不到任何相关内容。
答案 0 :(得分:1)
您可以直接加载图像字节,然后在创建联系人后将其传入。
set theImageFile to a reference to POSIX file "/Users/maximiliantyrtania/Pictures/image-151718-galleryV9-zhek.jpg"
set img_file to open for access theImageFile
set img_data to read img_file as "JPEG"
tell application "Microsoft Outlook"
set new_contact to make new contact with properties {first name:"Joan", last name:"Smith", email addresses:{{address:"work@mywork.com", type:work}, {address:"home@myhome.com", type:home}}}
set the image of new_contact to img_data
end tell
这也是一种很好的做法,可以将上面的图像读取错误。