AppleScript: Change an order of texts and HTML file in the body of Mail

I would like to know how to insert a HTML file below the Signature in the body of Email.
This is my code,,,,
set the clipboard to (read (choose file) as «class RTF »)
set theBody to "Hello"
tell application "Mail"
activate
  set theMessage to make new outgoing message with properties {content:theBody, visible:true, subject:"mysubject"}
end tell
tell application "System Events"
  tell process "Mail"
  set focused of UI element 1 of scroll area 1 of window 1 to true
  keystroke "v" using command down
  end tell
end tell
What I would like to do is an order of body going like
From the top:
Body
Signature
HTML rtf file
Please teach me how to do!
Cheers,

Hi,
murrayshimada wrote:
Wondering how about inserting a HTML between body and signature? If you have a free time, please give me a tip again. Anyway, thank you for your help. Cheers,
You can set the order like this:
set the clipboard to (read (choose file) as «class RTF »)
set theBody to "Hello" & return & return -- need two return character to paste the clipboard after the body
tell application "Mail"
    activate
    set theMessage to make new outgoing message with properties {content:theBody, visible:true, subject:"mysubject"}
    my pasteToEnd()
    delay 0.6 -- need a delay to not remove the pasted text.
    set message signature of theMessage to signature 1 -- this put the signature after the text
end tell
on pasteToEnd()
    tell application "System Events"
        tell process "Mail"
            set focused of UI element 1 of scroll area 1 of window 1 to true
            key code 125 using command down -- (arrow down + command down) to set the insertion point to the end of text 
            keystroke "v" using command down
        end tell
    end tell
end pasteToEnd
Here's another example, the order =  the HTML, the body and the signature:
set the clipboard to (read (choose file) as «class RTF »)
set theBody to "Hello"
tell application "Mail"
    activate
    set theMessage to make new outgoing message with properties {content:"theBody", visible:true, subject:"mysubject"}
    my pasteAtBeginning() -- at beginning
    delay 0.6 -- need a delay to not remove the pasted text.
    set message signature of theMessage to signature 1 -- this put the signature after the text
end tell
on pasteAtBeginning()
    tell application "System Events"
        tell process "Mail"
            set focused of UI element 1 of scroll area 1 of window 1 to true -- this set the insertion point at beginning
            keystroke "v" using command down
            keystroke return & return -- to put a blank line between the RTF and the body
        end tell
    end tell
end pasteAtBeginning

Similar Messages

  • AppleScript: Add a HTML file in the body of Email by the clipboard

    I would like to insert a HTML file into the body of Email by the clipboard action.
    This is my cord below:
    set the clipboard to (read (choose file) as «class RTF »)
    set theBody to "Hello"
    tell application "Mail"
    activate
      set theMessage to make new outgoing message with properties {content:theBody, visible:true, subject:"mysubject"}
    end tell
    tell application "System Events"
      tell process "Mail"
      set focused of UI element 1 of scroll area 1 of window 1 to true
      keystroke "v" using command down
      end tell
    end tell
    This code enables only rtf file rather than HTML.
    Also I don't want to use the html content by the function of Mail.
    Because if using it, you won't insert both  a html file and body at the same time.
    So what I would like to is to insert a HTML file by the clipboard action into a body.
    Thank you!

    Hi,
    One solution is to use Safari to copy the document:
    set x to choose file -- a HTML file
    tell application "Safari"
        open x
        delay 2
        repeat while source of document 1 does not contain "</html>"
            delay 1.5
        end repeat
        activate
    end tell
    tell application "System Events"
        tell process "Safari"
            set frontmost to true
            keystroke "a" using command down -- select all
            delay 0.3
            keystroke "c" using command down -- copy to clipboard
        end tell
    end tell
    set theBody to "Hello"
    tell application "Mail"
        activate
        set theMessage to make new outgoing message with properties {content:theBody, visible:true, subject:"mysubject"}
    end tell
    tell application "System Events"
        tell process "Mail"
            set focused of UI element 1 of scroll area 1 of window 1 to true
            keystroke "v" using command down
        end tell
    end tell
    Also try this:
    set the clipboard to (read (choose file) as «class HTML») -- a HTML file

  • A working method to load local PDF and HTML files on iOS

    I had a lot of trouble getting this to work, and I'm hoping this post saves someone time. Some of the information that's been posted in other locations is either wrong, incomplete, or might only work on Android. By the time you read this message the information here may no longer be accurate, so here's the testing environment:
    Window 7
    Flash CS 5.5.0
    AIR 2.7.0.19530, which was compiled on June 28, 2011
    iPad 1, version 4.3.5 of iOS
    Let's get started.
    On iOS, you load external PDF and HTML files using the StageWebView class.
    On Windows, StageWebView works but the HTMLLoader class is a better choice if you're creating a desktop app.
    You can also load HTML files by reading in the file's text. The information in this post is only for loading external HTML files.
    StageWebView will not load a file that's in File.applicationDirectory. All files bundled in your app are placed in File.applicationDirectory, which means you'll have to copy any external file you wish to load with StageWebView to another directory.
    So where can you copy your file? File.applicationStorageDirectory won't work. File.documentsDirectory does work.
    Several people have recommended copying to a temporary file using File.createTempFile(). This works, but there's a catch: it seems that, like Windows, StageWebView relies on a file's extension when determining how to load it. When you create a temporary file on iOS using File.createTempFile(), the file will have no extension (and on Windows, File.createTempFile() creates a file with the extension .tmp, which is equally problematic).
    The solution to the file extension problem is to rename the temporary file by appending the original file's extension. AIR currently does not have a <file>.rename() function, so you'll have to do it using <tempFile>.moveTo().
    Here's some code I've successfully tested several times on both iOS and Windows. The file is copied to the temp directory. The file's extension is restored by just slapping the original file name to the end of the temp file.
            private function loadExternalFile():void
                var webView = new StageWebView();
                webView.stage = this.stage;
                webView.viewPort = new Rectangle( 0, 0, 1024, 555 );
                // Works with either html or pdf files.
                // These are stored in the root of the application directory.
                var fileName:String = "euei.pdf";
                //var fileName:String = "euei.htm";
                var sourceFile = File.applicationDirectory.resolvePath( fileName );
                var workingFile = File.createTempFile();
                try
                    sourceFile.copyTo( workingFile, true );
                    // You have to rename the temp file
                    var renamedTempFile:File = workingFile.resolvePath(workingFile.nativePath + fileName);
                    workingFile.moveTo(renamedTempFile, true);
                    webView.loadURL( renamedTempFile.url );
                catch (err:Error) { }

    I tried this with Flash CS5.5 and AIR 4.0 SDK. Any pdf loaded simply fills the viewPort with black. Also tested with a png version of the pdf and that displayed just fine.
    What's the purpose of copying to a temp work file? I found that webView.loadURL( sourceFile.url ); gave me the exact same results.
    Any ideas?
    Thanks!

  • Html file in the content of email.

    hi friends,
    I want to send email in the html format.
    can we pass the html file in the content of mail?
    i.e instead of doing this
    messageBodyPart.setContent("<html><body> " +
    "--------------------------------------------------------------------------------<br><br>"+
    ""+firstLine+"<br><br></body></html>" );
    can I directly pass the html file?
    Also if we have images in the html is there any way that instead of hot linking the images we can attach them with mail?

    Supplying the html content using a file instead of a String is easy:
    messageBodyPart.setDataHandler(new FileDataSource("file.html"));
    To include images in the message is harder, see the FAQ.

  • Changed Purchase order triggering Email and Fax to vendor

    Hello,
    Ecc6.0 srm3.0.
    a changed purchase order triggering email to vendor, although in the table BBPD_PO_METAOUT all the fields are unchecked and we donu2019t have customization in the table BBPD_COMP_FIELDS,
    Please suggest, we donu2019t want email of fax to be triggered when we amend the purchase order,
    Thanks for reply.
    jairaj

    When we change vendor text, It is SAP std that mail will triger to vendor

  • How do I mix text and Html format in a java mail?

    How do I mix text and Html format in a java mail? some part I want to keep the text format, the other part I want to use Html functions(like fond, color, etc)

    You don't mix them. Pick one or the other.
    However if you want to have a text version and an HTML version, so that mail readers that don't handle HTML can see regular text instead, then you could produce a "multipart/alternative" message. There's an explanation of how to do that in this article:
    http://www-128.ibm.com/developerworks/java/library/x-xmlist2/

  • How do I restore my preferred icon for .htm and .html files? search keyword axolotl

    When I made Firefox 3.6.2 my default browser, it changed the icons for my .htm & .html files to the fox&globe symbol - how do I change back to my old red dragon symbol? Folder options doesn't work, the icon for the file type changes in folder options, but has no effect on the icon displayed by Windows XP Explorer. Changing registry entries for DefaultIcon from ...\firefox.exe,1 to ....\mozilla.ico also failed, the WxExplorer icons changed to a generic symbol. Thanks, [email protected]
    search keyword axolotl

    With the help of information from user, ptressel, in [https://support.mozilla.org/en-US/questions/1032154#answer-673322 a post here about the existence of sessionstore.js when version 33 was released], I was able to easily recover my tabs and tab groups as follows:
    # close Firefox and, perhaps, allow a few seconds (30s?) for any final closing of files;
    # check to see if you have a sessionstore.js file in your profile folder, named like the one I documented in my original post above;
    # if it is not timestamped prior to the discovery of your problem, open the sessionstore-backups folder;
    # check if the recovery.js file is suitably timestamped and, if not, the recovery.bak.
    # At this point, you are likely to find that none of them are prior to your problem occuring. If so, open your backups of this folder and go through steps 2-4 to find a file prior to your problem occuring.
    # When you find a file, copy it to the root of your current profile folder and name it, "sessionstore.js"
    # Open Firefox. Mine opened up as desired.
    This is a Windows solution. Sorry I can't comment on other platforms, but I'd bet that as this is just a file copy and renaming, it is likely the same.
    For Windows users, you may find you need to sign out and login as an administrator in order to access the backups. You need not logoff your standard account, but do have Firefox closed as described above.
    Hope that helps.

  • "texts on html file" are not updated "when edited on server"

    Hi All,
    QUESTION
    What are the solutions, for having editable text/content on .html published files, so clients can edit through their server control panel
    Scenario:
    Client wants to update the "text" by editing the .html files on a server.
    I published the website as static html so the text can be included in .html file, but edits made on server's control panel, doesnt appear in live website.
    I also noticed that the texts located in edgeActions.js are editable through server, i am not very interested to define all my text content as the dynamic
    code because then I must worry about empty .html files and SEO questions.

    Here is what I ve found in regard to my own question...
    For a Client, to be able to change the text on server (Ex: phone numbers in a contact page), they should access and modify the text in the   edge.js or sometimes edgeaction.js page. Changing the text on .html page will create no result. I assume, this is because, the .html page is exported ONCE and only at the point of Publishing a project, to satisfy the SEO needs or whatever. Think of the text on .html page as a Sticker to fool the rest of the world, changing it will not change anything on webste and. Also if you change the text in .js, the change will not be relfected on .html file.

  • Pls Help--- URGENT... Combining XML file and HTML file Using java program.

    Hi, I need to implemnt this for my project....
    I need to combine XML and HTML file and generate a new HTML file
    Sample XML File:
    <user>
    <txtName>sun</txtName>
    <txtAge>21 </txtAge>
    </user>
    Sample HTML File:
    <body>
    Name: <input type="text" name="txtName" value=""
    Age : <input type="text" Age="txtAge" value=""
    </body>
    I need a java program to combine the above xml and html files and generate the output in HTML.
    Any kind of help is sincerely Appreciated.
    Thanks.

    toucansam wrote:
    So you want us to write it for you? It's pretty straight forward, first parse the xml file with the *[best java xml parser|http://www.google.com/search?&q=parsing+xml+in+java]* and then go through the nodes and construct the html with strings and concatination. Then write the file using *[the best java file writer|http://www.google.com/search?hl=en&q=writing+to+a+file+in+java]*.
    He would do better to use existing tools that make this easy [http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html|http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html]

  • Can we have the text and value displayed in the BI Graph ?

    Dear Experts,
    We are able to see the graph for a particular report in switching to Graphical Display
    :I have selected Pie chart and the value and text is displayed on mouse over on each section.
    Please let meknow if there ia an option to display the text and value along with the graph.
    Regards
    Manu

    Manu Govind wrote:
    Dear Experts,
    >
    > We are able to see the graph for a particular report in switching to Graphical Display
    >
    > :I have selected Pie chart and the value and text is displayed on mouse over on each section.
    >
    > Please let meknow if there ia an option to display the text and value along with the graph.
    >
    >
    >
    > Regards
    > Manu
    Dear Govind,
    You can use BEx based WAD tool to acheive it. Edit the chart in the chart properties dialog, goto settings & edit the property. As you have requested you created 2 tabs, one for chart, another for data, and as and when you do changes in the Analysis grid, the chart values get adjusted.
    P.S. Humbly a personal opinion; I do not recommend WAD; use XCELCIUS instead.
    Best Regards, @{

  • Whenever i try to buy a new song or download an app my ipod says that "your apple id has been disabled" i have changed my password several times and it still says the same thing what can i do???

    Whenever i try to buy a new song or download an app my ipod says that "your apple id has been disabled" i have changed my password several times and it still says the same thing. What can i do???

    This may provide the answer:
    Apple ID: "This Apple ID has been disabled for security reasons" alert appears

  • I'm trying to download a purchased app but it keeps telling me my apple ID has been disabled. I've changed my password 3 times and it still says the same thing. what do I do?

    I'm trying to download a purchased app but it keeps telling me my apple ID has been disabled. I've changed my password 3 times and it still says the same thing. what do I do?

    Contact itunes support.

  • TS2167 I changed my header in iweb and when I published the site the font had shrunk and it displayed incorrectly. It was only on my home page, not on others. I have iweb 3.0.4. Help!?!?

    I changed my header in iweb and when I published the site the font had shrunk and it displayed incorrectly. It was only on my home page, not on others. I have iweb 3.0.4. Help!?!?

    Just in-case anyone els runs into this, I figured it out... I was working from my hotel and apperantly the fire wall was not allowing anything to uplaod, but I wasn't getting an error message from iweb, it would say that everything was published succesfully even though it wasn't. Once I went home and used my connection eveything worked fine.

  • When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

    When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

    When I change the time zone of the clock, the "Date created" time information for my documents and image files in the Finder window (and in Get Info) is changed. Can I make the time info in "Date created" remain fixed regardless of the clock's timezone?

  • How can I stop Photoshop CS5.5 taking control of html and pdf files without the user's consent?

    Our client uses CS 5.5, and Photoshop will continuously take control of pdf and html files. This is without any interraction from the user, and after setting it back to the desired settings (pdf - Reader, html - Chrome), after some time (and doesn't seem to be related to anything the user does, restarting machine etc), Photoshop will snatch control of either or both of these extensions.
    Could you please advise on how best to deal with this issue? Resetting Photoshop preferences does work for a time but it is not long before the issues arise again.

    Thank you for the link, it is an encouraging read as I have not yet found anything even similar to my issue via searches.
    The machine has never had a previous version of Photoshop installed, but it does have Elements, which is used for scanning documents (which are then edited in photoshop and converted to pdf there). It is an involved process.
    Although I appreciate the link and your time, I'm afraid the issue in the link is the opposite issue - the other user cannot set the default, whereas my user cannot unset the default.

Maybe you are looking for

  • Syncing apps to iTunes with Family Sharing

    I recently got a new iPhone 6 Plus and decided to use my own Apple ID instead of using my fathers, which I used on my old phone.  I got all the apps that I wanted from the new family sharing option.  However, when I sync my phone to my computer, unde

  • Whenever I connect my iPhone 4s to my Windows 8.1 pc with iTunes 10.6.3.25, the iTunes freezes.

    Whenever I connect my iPhone 4s to my Windows 8.1 pc with iTunes 10.6.3.25, the iTunes freezes and the only way to proceed is to kill the task under task manager. I have uninstalled iTunes following the recommended order and reinstalled numerous time

  • Problem with colors showing in PE10

    Is there a known problem with color in Elements 10? I have a gif that when opened in paint shows the light blue color correctly but in PSE10 shows as a buff color. Red, yellow and blue seem about right. It doesnt matter if it is the gif or the psd fi

  • Dchroot - where can i find it?

    hello! i installed a 32bit chroot in /opt/arch32 as written on http://wiki.archlinux.org/index.php/Arc - bit_system. now i need dchroot, but that is not avaible via pacman: bash-3.2# pacman -Ss schroot bash-3.2# pacman -Ss chroot extra/fakechroot 2.6

  • EWA Alert configuration done but report is not generated

    I have setup the EWA congiguration for a Solman 7.0 , i executed rtcctool and implemented addons now everything is seen in green , also activated SDCCN and checked for all RFC ...everything is working fine .i saw two tasks service preparation check a