Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Adding Hyperlinked Image Attachment To an E-mail

tell application "Mail"


set thePath to choose file

tell application "System Events"

set theAttachment to path of thePath

end tell


set theSender to "name@damain.com"



-- In the unedited script, the content would be entered via dialog boxes.

set theSubject to "Testing: 1, 2, 3…"

set theBody to "This is a test."



-- In the unedited script, the recipient information would be retrieved from a txt file.

set emailAddress to "recipient@domain.com"

set emailName to "John Smith"


set theContent to emailName & "," & return & return & theBody & return & return


set theMessage to makenewoutgoing messagewith properties {subject:theSubject, content:theContent, visible:true}

set sender of theMessage to theSender


tell theMessage


makenewto recipientat end of every to recipientwith properties {address:emailAddress}


makenewattachmentwith properties {file name:theAttachment as alias}

end tell



--send theMessage


end tell

Posted on Jan 22, 2014 10:09 AM

Reply
17 replies

Jan 26, 2014 2:09 PM in response to Pierre L.

I have now discovered that a few years ago my method of embedding image data in the HTML of emails was popular as it appeared to overcome some image blocking but since then it became a technique used by spammers and penalized by spam filters.


According to this link the only widely accepted method is to use a cid (Content ID) for all email images.


You can view the raw source of a received email to see if a cid has been used.


My tests indicate that Pierre's method and my Mail 3.6 modification do use a cid and hence should be widely accepted.


Thunderbird appears to always use a cid but my Apple Mail 3.6 only uses them under certain conditions - this is probably the reason for MS email products not always displaying Apple Mail generated images as expected.


A few tests later: As far as I can tell Apple Mail 3.6 only uses a cid if a normal image (not embedded image data) is surrounded by html tags, for example a link. Strangely an email consisting of only an image can be converted to cid by selecting the image and changing its font style. I am not sure about later versions of Mail. I wonder if this is a satisfactory fix for those who discover their Mail images are not displaying correctly in Outlook.

Jan 27, 2014 5:03 AM in response to Neville Hillyer

I apologise for posting this on this thread but having started investigating I thought it best to correct a few of my earlier misconceptions.


Further Mail 3.6 tests indicate that:


  1. Both Mail and Thunderbird use cid for embedded images in HTML emails
  2. Thunderbird also uses cid for the HTML part if the email has both text and HTML
  3. Mail also normally uses cid for the HTML part if the email has both text and HTML but see item 12
  4. Neither use cid for text emails
  5. The link in my earlier post was only concerned with HTML emails
  6. Thunderbird has a setting for composing HTML or text emails
  7. Mail has a setting for 'Rich Text' emails
  8. Thunderbird sends attached images without a cid but uses a cid for images within the HTML
  9. The use of cid appears reasonably predictable with Thunderbird
  10. The use of cid with Mail is less obvious
  11. AppleScript generated HTML Mail emails with both text and image do have cid
  12. Manually generated HTML Mail emails with both text and image do not have cid unless edited with extra tags

Adding Hyperlinked Image Attachment To an E-mail

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.