Find & replace in HTML mail message to change color

I have a script someone wrote for me to automatically print my school's attendance list when it comes into my inbox. I have a very limited understanding of AppleScript, but it seems to clean up the message and then send it to print. The one thing I would like to change is the color of the banner at the top of the page which is blue (coded cyan in the html) since it keeps using up all of the blue ink in my printer before the other colors. I am pasting the script below. How can I include some lines that will change cyan to gray or even white?
Anthony
on performmailaction(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
repeat with eachMsg in selectedMessages
set theSource to source of eachMsg as text
set AppleScript's text item delimiters to (ASCII character 10) & (ASCII character 10)
set theSource to text items 2 thru -1 of theSource as text
set AppleScript's text item delimiters to "=" & (ASCII character 10)
set theSourceItems to text items of theSource
set AppleScript's text item delimiters to ""
set theSource to theSourceItems as text
set AppleScript's text item delimiters to "=3D"
set theSourceItems to text items of theSource
set AppleScript's text item delimiters to "="
set theSource to theSourceItems as text
set AppleScript's text item delimiters to "=20"
set theSourceItems to text items of theSource
set AppleScript's text item delimiters to " "
set theSource to theSourceItems as text
set AppleScript's text item delimiters to "</HTML>"
set theSource to text item 1 of theSource as text
set AppleScript's text item delimiters to "<PRE>"
set theSourceItems to text items of theSource
set AppleScript's text item delimiters to ""
set theSource to theSourceItems as text
set AppleScript's text item delimiters to "</PRE>"
set theSourceItems to text items of theSource
set AppleScript's text item delimiters to ""
set theSource to theSourceItems as text
set theFile to open for access (((path to desktop folder) as text) & "Mail_tmp.html") with write permission
set eof of theFile to 0
write theSource & "</HTML>" to theFile starting at eof
close access (((path to desktop folder) as text) & "Mail_tmp.html") as file specification
tell application "Finder"
print alias (((path to desktop folder) as text) & "Mail_tmp.html")
delete alias (((path to desktop folder) as text) & "Mail_tmp.html")
end tell
end repeat
tell application "TextEdit"
quit
end tell
end tell
end performmailaction

Hello
As my goal is only to check that what I wrote runs correctly, I commented all your code which is not of "my responsability".
I ran the "stripped code" and got exactly what was wished: the words "Date:" and "Subject:" are in bold while all the remaining text is in plain .
At this time I am unable to apply Times to the plain text.
You may check the "stripped script" and when you will be convinced that this piece of code does its duty, you will have to search what is the wrongdoer in your own code.
-- [SCRIPT]
tell application "Mail"
activate
set selectedMessages to the selected messages of front message viewer
set saveFolder to choose folder with prompt "Please pick an empty folder for me to store the manuscript information:"
tell application "Finder"
set parentFolder to folder saveFolder
set parentFolderPath to parentFolder as Unicode text
end tell -- to Finder
repeat with aMessage in selectedMessages
properties of aMessage
set messageSender to sender of aMessage
set messageSubject to subject of aMessage
set messageSent to date sent of aMessage as string
set messageContent to content of aMessage
if (messageSender is "[email protected]") and (messageSubject begins with "manuscript #") then
-- Get manuscript number from message subject after '#'
set oldDelimiter to my SwitchDelimiterTo({"#"})
set manuscriptNumber to last text item of messageSubject
my SwitchDelimiterTo(oldDelimiter)
log "NOTE: Email for manuscript #" & manuscriptNumber
-- Make the folder in which to store the stuff for this manuscript;
-- variable "manuscriptFolder" will point to place to store files
tell application "Finder"
try --ignore problems with folder creation, like existing folders/files
set manuscriptFolder to make new folder in parentFolder with properties {name:manuscriptNumber}
on error errorName number errorNumber
if errorNumber is -48 then -- Folder already exists
log "NOTE: folder " & parentFolderPath & manuscriptNumber & " already exists."
set manuscriptFolder to folder manuscriptNumber in parentFolder
end if
end try
end tell -- to Finder
set manuscriptFolderPath to manuscriptFolder as Unicode text
set messageFileName to manuscriptFolderPath & "email.rtf"
log "NOTE: Saving manuscript to file: " & messageFileName
-- Use TextEdit to construct an RTF file of the message to print out later
set messageSent to "mardi 13 mars 2007"
set messageSubject to "sujet du message"
set messageContent to "blablabla…"
tell application "TextEdit"
activate
close every document saving no
set aDocument to make new document at beginning of documents
set fontReg to "Courier New"
set fontBold to "Courier New Bold"
set font of aDocument to fontReg
-- Assemble the document using the clipboard and pasting
-- Stick in "Date:"
set the clipboard to "Date:"
my triggerCmdKey("v", "TextEdit") -- Cmd-v, paste
set font of last word of document 1 to fontBold
-- Stick in date string
set the clipboard to tab & tab & messageSent & return
my triggerCmdKey("v", "TextEdit") -- Cmd-v, paste
-- Stick in "Subject:" and boldify it
set the clipboard to "Subject:"
my triggerCmdKey("v", "TextEdit") -- Cmd-v, paste
delay 1
set font of last word of document 1 to fontBold
-- Stick in the subject
set the clipboard to tab & messageSubject & return & return
my triggerCmdKey("v", "TextEdit") -- Cmd-v, paste
-- Stick in the message content
set the clipboard to messageContent & return
my triggerCmdKey("v", "TextEdit") -- Cmd-v, paste
-- Save the document as an RTF in the messageFileName
tell front document
save in messageFileName
end tell -- to front document
end tell -- to TextEdit
else
log "Message from \"" & messageSender & "\" with subject \"" & messageSubject & "\" will not be processed."
end if
end repeat
end tell -- to Mail
-- Change the text item delimiter and return the existing ones
on SwitchDelimiterTo(delimiterList)
local x
set x to (get AppleScript's text item delimiters)
set AppleScript's text item delimiters to delimiterList
return x
end SwitchDelimiterTo
-- Trigger a System Event for a Command-<key> in the named application
on triggerCmdKey(k, appName)
tell application appName to activate
tell application "System Events" to tell application process appName to keystroke k using {command down}
end triggerCmdKey
--[/SCRIPT]
Yvan KOENIG (from FRANCE jeudi 15 mars 2007 21:09:53)

Similar Messages

  • Using Safari to send HTML Mail message but Mail keeps dropping images?

    I'd like to use Safari to send html Mail messages, but when I click on File>Mail Contents... Mail opens a new window but my graphics are gone. (I'm creating the html pages using MS Word for the Mac.) I get a flash of the graphics for a second, and then they are replaced by a little blue lego. Any ideas? I've tried all kinds of mail preferences but nothing seems to help.

    Figured it out (at least one way): had to load the image to a server and then add the image as a link only (uncheck "save picture with document" box).

  • HTML Mail message deletion

    After installing the new Leopard OS, deleting any single html mail message (such as Borders or Amazon announcements) can take up to five minutes. If I shift and delete several items at once, up to ten minutes. Why is it so slow when it used to be an instantaneous deletion?

    After installing the new Leopard OS, deleting any single html mail message (such as Borders or Amazon announcements) can take up to five minutes. If I shift and delete several items at once, up to ten minutes. Why is it so slow when it used to be an instantaneous deletion?

  • Mail in inbox replaced by old mail messages when opened

    My computer was recently worked on and I'm not sure if that has anything to do with this but I thought it worth noting. I had to use time machine to put all my application data back onto apple mail and I started encountering problems pretty quickly. About 3-4 times a week when I go to look at my new mail in the morning, several of my mail messages are replaced by old messages from my inbox. They show up when I open my gmail account online but even when these messages are saved into folders they still retain the form of the old message. Has this happened to anyone before? Is there a solution? I might not have explained myself well, but hopefully someone will get the point.

    You probably have two good ways to go -- one, you could merely remove the IMAP accounts, and set them up again, which since everything is on the server, Mail would again index them when setting newly accessing them.
    The second, and probably better way to go, is as follows: Force a reindexing by deleting the Envelope Index. With IMAP or Exchange account, forcing reindexing requires removing the account folder. See:
    http://docs.info.apple.com/article.html?path=Mail/4.0/en/14019.html
    This method with be sure to reindex any On My Mac mailboxes. Ask any questions needed to get comfortable with doing this.
    Ernie

  • Using AppleScript to find specific text in mail message?

    I'm new to scripting, and I'm a bit lost on this one...
    Is there any way to use AppleScript to find a file name from within the body of a mail message so it can be used later in the script?
    Specifically, I want to use AppleScript to "read" the content of a mail message and look for a paragraph that says "Filename: MyFileName" so I can set "MyFileName" as a variable. (There will always be a paragraph that begins with "Filename: " in this particular email message.)
    This will part of a larger script that uses Fetch to download "MyFileName" from our FTP server.
    Thanks in advance for any ideas - I'm struggling with this one.
    Andy Gill

    Ok, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
    To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
    The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
    I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
    using terms from application "Mail"
    on perform mail action with messages theSelectedMessages for rule theRule
    repeat with aCounter from 1 to count theSelectedMessages
    set theMessage to item aCounter of theSelectedMessages
    set theContent to content of theMessage
    set theWords to every word of theContent
    set theFilename to {}
    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to ":"
    repeat with thisLoop in theWords
    try
    if (text item 1 of thisLoop) is "Filename" then
    set end of theFilename to (text item 2 of thisLoop)
    -- rest of your logic goes here the display is just to show it finds the filename, take it out!
    display dialog theFilename ¬
    buttons {"OK"}
    end if
    end try
    end repeat
    set AppleScript's text item delimiters to tid
    end repeat
    end perform mail action with messages
    end using terms from
    Message was edited by: stephen.bradley Typos for the win!

  • Hyperlink in mail message gets changed

    I'm having trouble mailing webpage addresses. If I copy and paste an address into an email the entire thing does not get underlined so when recipients click on it they don't get the entire address. If I use mail/edit/add hyperlink and paste the address into the hyperlink address box, it gets changed; after the % extra characters are getting pasted in.
    anyone else having this problem or know what to do about it?
    thanks!
    iBook G4   Mac OS X (10.4.7)  

    They get added because when replying, or forwarding
    an e-mail you get quotes added as well as spaces.
    And e-mail programs don't deal with long strings of
    text very well.
    thanks for the help! I'm a regular subscriber to tinyurl now! My next problem is figuring out how to get my movies viewed by folks.

  • HT201320 Can't find my sent e-mail messages

    Hello All-
    I have my e-mail set up, but, I cannot see my outbox, or drafts, only my inbox.
    Thanks,
    Dee Anna

    Scroll down in the Mail app to the Accounts section and tap on the account name.
    Note that unless you have an MS Exchange, iCloud or IMAP account you will not see messages sent from your computer, only those you send from the phone. And even for those there will be nothing there until you open the folder, which causes it to sync with the server.

  • RH8 - Any way to chage styles besides risky HTML find/replace

    Hi - We have created a new .css with updated styles. All the TWs must now manually apply the new styles in every topic, a time consuming task. I know there's the option of doing a find/replace in all topics that will change the HTML, but RH doesn't respond well given its tendency to add tags in the name of being helpful. Attempted to a find/replace and it worked for a heading, but when I went on to a custom paragraph style, the result was not good. Ended up going back to my backup from that day.
    Any suggestions/advice? Has Adobe provided anything in way of a tool that we can use?

    Use Find & Replace
    Search: Specific Tag        p
    + With Attribute                style   =   [any value]
    Action: Remove Attribute   style
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • How do I integrate sound within a mail message?

    Hello,
    I need to integrate sound within a mail message. That is, when the recipient gets the message the sound will autoplay.
    I tried attaching the sound file (small mp3) to an HTML mail message and autoplay it using the BGSOUND or EMBED HTML tags (referring to a content-id that I set with MimeBodyPart.setHeader( ) ), but the sound was not played when the message was opened by the recipient...
    Any suggestions?
    Thanks,
    Lior.

    Of course not. Mail clients are being fixed so that they don't automatically execute attachments in messages any more. Far too many viruses were being spread that way. Even JPG images were being used to transmit viruses.

  • Can no longer change fonts in Mail messages

    All of the sudden (within the last couple of days), I find I can no longer change the font - or even the style (bold, italic) of any new mail message. I can change the color, but that's about it. The font stays as whatever the default Message Font is. I did try changing the default to verify it was not a font corruption issue.
    I don't think it's a font panel issue since I can change Fonts, Styles, etc. in other apps that use the Font Panel.
    Anyone have any thoughts?
    Thanks up front.
    -fQ-

    Some more tests .. it's definitely not the app itself .. I booted from my external .. and I launched the Mail app on my main .. and it worked fine (of course, all my accounts, etc weren't there) .. so you're right .. it's either a prefs thing (though not the "com.apple.mail.plist" file since opening a brand new user still has the same problem).. or maybe even a corrupt .pkg file in Receipts .. wait a sec .. replaced the Mail.pkg file just to check .. still nope. So it's gotta be something low level.
    At this point, I'm thinking what may be easier on both of us is ... I'm waiting for the Apple Box Set (Leopard/iLife 09/iWork 09) to start shipping before I upgrade .. that should be pretty soon .. so I'll just hand on till then (it's really not all that big a deal I guess in the big picture .. just irritating) .. and see if upgrading corrects the issue .. if not, then I guess I'm off bug hunting again.
    Again .. thanks ever so much for your time and effort.
    I'll post back here with the results either way.

  • Find & Replace text in html files

    This is my first real attempt at using Automator, and it has become increasingly frustrating for me. I love the idea of Automator, nice interface, and it appears to be so easy to use. But, I can't get it to actually DO anything and I don't understand why.
    Here is my goal:
    to batch process multiple html files to remove certain characters and words (or replace them with empty space).
    I currently open these files in Pages and do 6 separate Find & Replace commands for each file before I continue with my other processing tasks. This is very tedious and I believe the computer should be able to find & replace multiple items at one time. (I have used other utilities to do batch renaming and trimming file names before.)
    All I want to do is select a group of files (usually 25 at a time) and have Automator get rid of all the unwanted words and characters before I open each file for final processing in Pages. I found a set of Automator actions for TextEdit which includes a Find & Replace action, but I've wasted over an hour so far trying to get it to work.
    When I run the workflow, it acts like it's doing something, but the files remain unchanged. I have tried using actions such as Read Text File, Get Contents of TextEdit Document, Set Contents of TextEdit Document, along with 6 instances of Find & Replace, but I cannot get it to work.
    I'm at a point today where I cannot afford to mess around with this anymore. I have to do it the long way in Pages or else I'll never get it done, but I want to get these Automator workflows to work before I have to repeat this task. (I do this at least once a week right now.)
    Any ideas or suggestions? I've tried reading in the help menus and support pages, but perhaps I'm just not understanding something here.

    Any ideas or suggestions?
    You might be interested in using TextWrangler. It can perform batch find-and-replace changes across multiple selected files.
    Good luck!
    Andrew99

  • Can't edit outlook email in HTML- whole message replaced with "undefined".

    In editing the html of messages in Outlook using Firefox browser, I click on options -> edit in HTML and whether or not I do anything to change the email whilst in the HTML editing option, as soon as I click on Rich Text to check the formatting etc the whole body of the email is replaced with the word 'undefined' and there is no access to saved drafts of that message.
    This has been happening for several months now and it's mega frustrating. I would appreciate any light being thrown onto this issue, thanks

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Gifs changing to Blurry Jpgs when attached to Mail Messages

    Hi,
    I frequently pass screen shots to colleagues via email. I usually save these as gifs. When I attach a gif to an email, it automatically converts to a jpg and becomes extremely blurry. If I go to my provider's email browser and attach the same files, they remain as gifs and are crisp and clean but this is a hassle.
    What's up with Mail?

    I've been a cell phone user since the early days of analog cellular. Back in the days of brick phones, of which I was a user.
    I've been a customer of of Cellular One, Ameritech, Verizon, T Mobile, Cingular and AT&T.
    I've never experienced loosing my voice mail as I did today.
    I considered my voice mail broken since I could not access my visual voice mail on my phone, I could not reset my voice mail on my phone (following the prompts on my phone) and no one could leave me a voice mail message if they called me. I called AT&T customer support and they could not get my voice mail working. I'm not sure what more could be broken, but I would classify my voice mail as broken.
    You may find it acceptable to have your voice mail broken (or perhaps cut off) if you change your data plan, but I don't think that's acceptable.
    I don't see how I made a major change to my account. I didn't make any changes to the types of data I can send or receive. The only change I made was to opt for a lower cost plan that delivers all the same data. That change resulted in all 5 members of my family plan to loose their voice mail.
    You may be correct that all this needed was for it to be reset. But, I can't reset it. The customer service person could not reset it. It took the tech support person to be able to reset it. All of which was about an hour on the phone.
    I don't think this experience should be typical. Maybe it isn't. Maybe for some strange reason, in my circumstance something more went wrong. But, that's not what AT&T told me. They told me what I experienced is typical.
    So, I thought I would post this for people that might experience this issue, or think about changing their data plan so that they would know what to do.
    But, perhaps I was wrong in using this Discussion site to post what I thought might be helpful.
    I'm sorry. I will (as I told a previous poster) delete this post. As soon I as I figure out how.

  • Finding of output mail message - NACE

    Dear colleagues,
    I would like to ask you if you can help me. In NACE - procedures for V3 I have for mail message requirement. I need to find this output only when invoice is created for the first time and transfered to accounting. I don't want to repeat finding of this message if invoice is changed after transfer to accounting.
    Is there any sign available here how to recognize this?
    It should be extension of standard requirement 060.
    Thank a lot.
    David Plaňanský

    Hi David,
    If you dont want to see the output type triggered for more than once in an invoice document, you can configure this in NACE.
    In NACE in V3, double click on the output type and you can see a check box called "Multiple Issuing". Make sure that it is not ticked on. If this is not clicked, the output will not be triggered more than once.
    However if you want to enter manually, this control is not applicable. You can always enter it manually.
    Hope it helps.

  • I can no longer receive e-mail messages through my @mac/@me account. I can still send e-mail messages, though. I believe there may have been recent attempts to hack into my account. I have changed my password, but wonder how to start receiving mail again?

    I can no longer receive e-mail messages through my @mac/@me account, though I still seem to be able to send messages. I believe there may have been recent attempts to hack into my Mail account (my LinkedIn and Facebook accounts were both hacked three days ago and a scam/phishing message sent to my contacts, and I know there was at least an attempt made to hack into one of my e-mail accounts). I have already changed my Apple password, but how do I start receiving mail again?
    (And I should also say that I'm a little surprised there was no alert from Apple of suspicious activity on my account, if such was the case. Instead, when I logged into my account via Mobile Me three days ago I noticed that all messages in my inbox were gone as well as all of my contacts. I assume this was related to the current problem.)
    Thanks for all responses.

    The problem has been solved with the help of a MobileMe online counsellor. My MobileMe account had in fact been hacked into and the fraudster had been redirecting my e-mail messages to a phony account that he controlled. We took the forward off and reset all my passwords and security questions, which solved the immediate problem.
    Thx.

Maybe you are looking for