title: Using a mail rule/Applescript/Automator flow to download a PDF behind an HTML button
body: <p>I'm receiving BCC emails from a branded photo activation and tasked with automatically saving a copy of the photo included with each email.</p>
  
  <p>The emails are HTML-coded and the link to the PDF I'm tasked with saving is attached to a button (i.e. "Click here to see your photo").</p>
  
  <p>I've successfully created the following flow, but it won't download the PDF from the HTML email, it will only download if the PDF is linked in plain text. Any help would getting the raw email would be greatly appreciated...</p>
  
  <ol>
  <li>Mail Rule to run AppleScript on all messages</li>
  <li><p>Applescript code:</p>
  
  <pre><code>   property workFlowPath : quoted form of ("/Users/USERNAME/Documents/Applescript/WORKFLOWNAME.workflow")
  
  
  using terms from application "Mail"
      on perform mail action with messages theMessages for rule theRule
          repeat with eachMessage in theMessages
      (*Get the email Subject *)
      set input_Argument to content of eachMessage
      (*Run subroutine for workflow *)
      my runAutomator(input_Argument)
    end repeat
   end perform mail action with messages
  end using terms from
  
  (*Workflow  Subroutine *)
  on runAutomator(input_Argument)
  
  (*Path to workflow *)
  
  
  (*Setup and Run the unix command *)
  set command to "/usr/bin/automator   -i " &amp; quoted form of    input_Argument &amp; space &amp; workFlowPath
  do shell script command
  end runAutomator
  </code></pre></li>
  <li><p>The workflow it triggers runs an automator flow that only saves files ending in ".pdf" to a designated folder</p></li>
  </ol>