Read email message with AppleScript
Hi!
I just used this tip to remotely sleep my MacBook Pro:
http://www.tuaw.com/2008/04/07/applescript-control-your-mac-with-an-e-mail/
Now I would like that when the message comes with the subject as System and the text as Read an applescript would read what I wrote after that.
Example:
From: Me
Subject: System
Text: Sleep
-> The computer runs applescript sleep and sleeps (so far it's working)
From: Me
Subject: System
Text: Read
-> The computer runs applescript read (that's the problem)
How do I point the AppleScript to the received message and make it start reading?
Is there a way to also unlock the screen (screensaver uses password)?
Tank-you in advance for any help!
The trick here (and the part that TUAW doesn't cover in that article) is that when a Mail rule triggers an AppleScript it passes a list of relevant messages to the script.
Once you have that it's easy to act upon the message content.
So instead of the simple shutdown script you write something more like:
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with eachMessage in theSelectedMessages
-- Process the current message
-- YOUR CODE HERE
end repeat
end perform mail action with messages
end using terms from
Similar Messages
-
You have now exceeded your iCloud storage, including an additional amount provided to allow you to continue receiving email. As a result, you will not be able to send or receive new email messages with your iCloud email address until you free up storage space or buy more storage. I have 20GB remaining. WHat is the issue here?
Today I received the same message but have 4.6gb available from a total of 5.0gb. I also received the same message when i first set up my icloud account and icloud was virtually empty. Unfortunately the only way i can see to contact apple is to pay for a telephone call. If anyone knows what is going on i would appreciate knowing.
-
How to Read a Message with Content Type multipart/alternative
Hi ,
I need to write a POP3 Client to read email message ..but some times the messages comes with content type multipart/alternative
how to parse it and read only one of the content :
for example :
This is a multi-part message in MIME format.
------=_NextPart_000_12C25_01C6B64F.09226B00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Assignment to workgroup Name 1 : L2 SD Service Delivery Apps Spt
Open CI Search Code : HPSD
Description : tesat
General Information :
Is the workgroup owner Aware of the addition to Workgroup : Yes
Workgroup to be added :
L2 SD Service Delivery Apps Spt
------=_NextPart_000_12C25_01C6B64F.09226B00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<br><P>Assignment to workgroup Name 1 : L2 SD Service Delivery Apps =
Spt</P>
<P>Open CI Search Code : HPSD</P>
<P>Description : tesat</P>
<P>General Information :</P>
<P>Is the workgroup owner Aware of the addition to Workgroup : Yes</P>
<P>Workgroup to be added :</P>
<P>L2 SD Service Delivery Apps Spt</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
------=_NextPart_000_12C25_01C6B64F.09226B00--
The Same message is in text as well as HTML so not sure how to read it .
currently my program is as follows
for (int i = 0; i < found.length; i++) {
Message m = found;
// Get some headers
Date date = m.getSentDate();
Address [] from = m.getFrom();
String subj = m.getSubject();
String mimeType = m.getContentType();
System.out.println(date + "\t" + from[0] + "\t" +
subj + "\t" + mimeType);
Object o = m.getContent();
if (o instanceof String) {
System.out.println("**This is a String Message**");
System.out.println((String)o);
} else if (o instanceof Multipart) {
System.out.print("**This is a Multipart Message. ");
Multipart mp = (Multipart)o;
int count3 = mp.getCount();
System.out.println("It has " + count3 +
" BodyParts in it**");
for (int j = 0; j < count3; j++) {
// Part are numbered starting at 0
BodyPart b = mp.getBodyPart(j);
String mimeType2 = b.getContentType();
System.out.println( "BodyPart " + (j + 1) +
" is of MimeType " + mimeType);
Object o2 = b.getContent();
if (o2 instanceof String) {
System.out.println("**This is a String BodyPart**");
System.out.println((String)o2);
} else if (o2 instanceof Multipart) {
System.out.print(
"**This BodyPart is a nested Multipart. ");
Multipart mp2 = (Multipart)o2;
int count2 = mp2.getCount();
System.out.println("It has " + count2 +
"further BodyParts in it**");
} else if (o2 instanceof InputStream) {
System.out.println(
"**This is an InputStream BodyPart**");
} //End of for
} else if (o instanceof InputStream) {
System.out.println("***********************************This is an InputStream message**");
InputStream is = (InputStream)o;
/* if(m.getContentType().equalsIgnoreCase("multipart/alternative")) {
MimeMultipart mp = new MimeMultipart();
// Assumes character content (not binary images)
} else {*/
BufferedReader reader
=new BufferedReader(new InputStreamReader(is));
String thisLine=reader.readLine();
while (thisLine!=null) {
System.out.println(thisLine);
thisLine=reader.readLine();
So when the Content TYpe is multipart/alternative it goes into InputStream message .
any help and ideas to handel such situations ?
Thanks
San
Message was edited by:
sanrosh_95Try reposting that with tags (replace the {'s with ['s).
Long story short, I think the FAQ and examples would go a long way towards explaining this, but you basically can check the content type, or check if the content contains parts, and parse each part separately. -
Why have I lost read email messages on my iphone?
I've only had my iphone 4 for a week or so. All of a sudden today I have lost my read email messages. I still have them on computer but lost them on the phone. Also lost my sent messages. I would like to get them back. My spouse also has same phone and the same thing happened on his phone as well.
What is the account type - POP or IMAP?
Sounds like the account is a POP accout is the sent messages are not available.
If so, what is the account setting with the email client used on your computer for accessing the account for removing messages from the server after being downloaded by the email client?
If the email client on your computer is removing messages from the server after being downloaded, the messages will be removed from your iPhone as well since the messages are no longer available on the server.
Although it is possible to access a POP account with more than one email client, a POP account is designed to be accessed with a single email client only. -
I have a problem never had B 4. Have installed new Win7 OS many times and imported windows mail. Always when choosing windows mail in FF it worked. Now when doing I get windows mail program opening or if open coming to forefront or screen. Supposed to get a new email message with subject and URL inserted. I have searched many answers fro FF & MS. I have set WinMail as default, add ed same in reg, etc. etc. Still NADA. Any ideas? thanks
You should post here:
Microsoft Office forums >
Word IT Pro Discussions
S.Sengupta, Windows Entertainment and Connected Home MVP -
How do you go back and read email messages stored in untitled 1
How do you go back and read email messages moved to untitled 1
Are you using Gmail? There is no "untitled" folder in my 3 mail accounts on the iPad so I am making an assumption here. If you are using Gmail, here is their help site.
http://support.google.com/mail/bin/answer.py?hl=en&answer=77702 -
Read email Message and process it
Hai friends..
I've just started working with the mail API.. I've gone through the code samples but couldn't get a clear picture on how to extract the body of an email message in some mailbox of mine.. Let me elabourate..
I have an email account say [email protected] which is an smtp based account
smtp address = smtp.mail.xyz.net
pop address = pop.mail.xyz.net
authentication id = abc, password = passwd
I want to extract the contents of an email residing in my INBOX using a java program.. Can somebody send a sample code of how to do this
Warm egards
DstTry something like:
Store store = null;
Folder folder = null;
try
// Get a Properties object
Properties props = System.getProperties();
// Get a Session object
Session session = Session.getDefaultInstance(props, null);
// Get a Store object
store = session.getStore("pop3"));
store.connect("mail.hostname.com", -1, "username", "password");
// Open the Folder
Folder root = store.getDefaultFolder();
if (root == null || !root.exists()) {
System.err.println("No default folder");
return;
folder = root.getFolder("INBOX");
if (folder == null || !folder.exists()) {
System.err.println("Unable to located folder INBOX");
return;
folder.open(Folder.READ_WRITE);
int totalMessages = folder.getMessageCount();
if (totalMessages == 0)
return;
// Attributes & Flags for all messages ..
Message[] msgs = folder.getMessages();
// Use a suitable FetchProfile
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
folder.fetch(msgs, fp);
for (int i = 0; i < msgs.length; i++)
// Do something with msgs;
// Do this to have msg deleted when you close mailbox
msgs[i].setFlag(Flags.Flag.DELETED, true);
catch (NoSuchProviderException e)
System.err.println("Unable to process mail for protocol of '" +
getMailProtocol());
catch (AuthenticationFailedException e)
System.err.println("The username/password was not accepted for the supplied host and port");
catch (MessagingException e)
System.err.println("Unable to process the mail: " + e.getMessage());
finally
if (folder != null)
try
folder.close(true);
catch (Exception e)
if (store != null)
try
store.close();
catch (Exception e) -
Nokia Email Messaging with Proxy
Hi
I am having problem with Nokia Messaging. I am using E71 in office but my office have proxy server. I have put down proxy settings into my WLAN > advance settings. i.e 10.10.xxx..xxx with port number 8881. When I am browsing internet it works fine, even i can use youtube and facebook. But Nokia email Messaging does not seems to be work. Has anyone got this problem. I have got firmwire version 3The proxy server is normally used only for web acess (HTTP/HTTPS), so I don't think any other application (messaging, fring, etc.) will even try to use it, and even if they do try to use, it will most likely not work..
-
Copying email content with AppleScript
I'm hoping someone out there can tell me what's going on here...
I'm trying to extract text from an email using an AppleScript. The script is being called by a mail rule based on a particular sender. The script I have cobbled together from a few online sources is:
tell application "Finder" to set ptd to "Macintosh HD:Users:Rob:Documents:Rob Woods Art:Vitec:Tasks:" as string
using terms from application "Mail"
on perform mail action with messages theIncomingMessages for rule theRule
tell application "Mail"
repeat with each_message in theIncomingMessages
set theText to content of theIncomingMessages
set theFile to ptd & "Task " & (theIncomingMessages's id as string)
set theFileID to open for access file theFile with write permission
write theText to theFileID
close access theFileID
end repeat
end tell
end perform mail action with messages
end using terms from
What should happen is I get a text file at the location defined at 'ptd' called 'Task (id)'. But I get nothing. I know the rule is running OK as it also plays a sound only on that rule.
I'm banging my head now! I'm running Snow Leopard if it makes any difference.
Thanks peeps.
RobIn case it helps debug this, I've been messing around and with the message selected, if I apply rules from the menu, I get what I expected - a txt file with the content written out. But it's only working because I have the message selected.
Does that ring any bells?
Rob -
How can I open multiple email messages with a single click?
On the Mac mini I use at work, I can select several email messages at a time and open them all up by double-clicking the mouse pointer on any of the selected messages. My MacBook Pro at home seems to lack that functionality, even though both are running the same version of Yosemite. In order to open up multiple messages (each, in its own window) on my MacBook Pro, I need to double-click on each individual message, even though I have multiple messages selected on my MacBook Pro, using Yosemite's Mail app. I assume there is an optional setting that can enable multiple messages to be opened by double-clicking on a single selected message, but I have looked through the Mail app's preferences and I come up empty handed. Can someone please clue me in on how to get this functionality on my MacBook Pro?
Hi,
There is another similar icon named Bookmarks in the '''Customize''' window which provides the said functionality. You have to add that. -
When sending an email message with attachment, the message disappears.
I send and receive messages without any problems but when I try sending a message with an attachment (using Documents to Go, IAnnotate PDF, IWork,) the message somehow disappears (it is not sent to the destination and not listed on "Sent" messages folder. Is anyone having the same issue?
Hi Jaime,
Are you saying, you are getting junk characters in the email attachment? Then pls check the following. Since you want to send Japanese fonts, please pass language 'J' in both objpack-obj_langu = '3' & doc_chng-obj_langu = '3' instead of '3' please replace it with 'J'.
Another thing which you may have to check is the SCOT device type. As I understand from my basis colleague, this may also affect your attachment fonts since the emails are sent through SCOT. Go to transaction SCOT-> Settings-> Device types for format conversion. Check whether wrong device type is defined for Japanese there. Hope this helps
Regards,
Gokul -
How to process received images in iChat/Messages with Applescript
Hello!
I want to process all received photos or videos with Applescript.
I try this:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
if the length of theMessage is 0 then
-- it means I received a picture or video file, but I can't get the file with Applescript, because theMessage is an empty string and not a file
set theMessage to "<lost photo or video content>"
else
-- it's OK, I just got a text message and I can now save it or display or do something else with it
end if
end message received
end using terms from
But if I receive a photo, theMessage is empty.
The event handlers "on completed file transfer" and "received file transfer invitation" don't work in this case, probably because it is not a file tranfer, but sort of an inline picture.
I use OS X 10.8.
Can somebody help me?I have a similar question as well. I tried this for you and nothing happened.
on received file transfer invitation theFileTransfer
end received file transfer invitation
I think "completed file transfer" is regarding to the file being transfered to Apple's Server from your computer when a file is sent, but I'm not sure about "received file transfer invitation." Regarding it being an inline file, maybe try using the attachment class.
attachment n [inh. rich text] : Represents an inline text attachment. This class is used mainly for make commands.
elements
contained by rich text, characters, paragraphs, words, attribute runs.
properties
file (file, r/o) : The path to the file for the attachment syn file name -
Place random image in Messages with Applescript - TextExpander
I've been using Apple computers since '84 but I've never used Appplescript and was hoping for some help.
I'd like to be able to place a random image in Messages with an Applescript through TextExpander. When I type my snippet into Messages the Finder will open a random image from a folder using something like this:
tell application "Finder"
set randomImage to some file of folder "Mac HD:Users:me:photos:chat pics"
get randomImage
open randomImage
end tell
If I replace "Finder" with "Messages" it doesn't work. Do I need to combine 2 Applescripts to make this happen?
TIAI tried using the following code, but it�din�t work.
<%@ page import="java.io.*" %>
<%
// File (or directory) to be moved
File file = new File("banner2.bmp");
// Destination directory
File dir = new File("banner");
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
System.out.println("File was not successfully moved");
// File was not successfully moved
else{
System.out.println("File was successfully moved");
%>Andreas -
How to move Mail.app messages with AppleScript
I have the following AppleScrip to move all Mail messages from one folder to another folder:
on run {input, parameters}
tell application "Mail"
repeat with theMessage in {messages in mailbox "Later" of account "[email protected]"}
set theMailbox to mailbox "INBOX" of account "[email protected]"
move theMessage to theMailbox
end repeat
end tell
return input
end run
When I run the script, it gives an error message:
Syntax Error. Mail got an error: Can't make {message id xxx} of mailbox "Later" of account "[email protected]" into type scpcifier.
What do I have to change to make this script work?What you are trying to do, move mail messages older than some time to a different folder, isn't really something that should be down by a rule. Rules are meant to examine messages as they arreive and to prefrom some action based on the mesage.
You would do better to make this a straight AppleScript that you would then run as needed or triggered by something like iCal on a daily basis. -
Cannot read email message body in Mail
Hello Pholks,
I'm running iBook G4 w/ OS 10.4.8. Upon starting my computer and Mail this morning, I have the following very strange problem - similar to one other who has posted today:
I can see messages in my Inbox. I can see sender, subject, date sent, etc...
However, when I highlight the message, the only thing that appears in the message windo is the header info (From: Subject: Date: To:) The body of the message is not visible. This is true for some of the messages in my Inbox, but not all. Some are old, some are new today.
Further: I also see this behavior in my archived messages. Picking a random mailbox on my hard drive, some message bodies are visible, others not. It appears to be random; I can't find any common link between the messages that aren't visible.
Further: If I use Entourage, I don't have this problem; that is, the message bodies that aren't visible in Mail are visible in Entourage.
Further: If I go onto my hard drive to the Inbox folder and select a .mbox folder and look at the messages, some have visible bodies, some not.
This appears to be a problem specific to Mail. Please help - many of my archived emails are no longer accessible to me.
Further: I've done two things that may have played a role. (1) I downloaded and installed software updates for iChat and the new Security update last night; (2) I've just added an external HD for backup. I tried to run a simple backup script last night, which resulted in the iBook HD chugging for quite some time, but never did put the data on the external HD. I've run "Repair Permissions" in Disk Utility, but to no avail.
HELP.....Thanks very much. It's turned out to be a font problem. About 30 of the fonts in my account directory /users/me/library/fonts folder were corrupted. They were somehow being viewed as unix executable files instead of font suitcases. !??! No idea what happened there.
I used Pacifist to reload fonts from my OSX installation disc, but this didn't seem to help. Instead, I found other copies of most of the corrupted fonts in the microsoft office/office/fonts folder, and replaced the corrupted fonts in my home library w/ those.
I was alerted to the fact the the problem was fonts when I tried to open an Excel file; it came back with messages that these various fonts were corrupted and needed to be removed. Strangely, though the corrupted fonts were in my home directory font folder and not the MS Office font folder, Excel was tripping up - i.e., it wasn't using the fonts from the Office folder. Hmm.
Finally, there are still a few fonts that are corrupted, and whose source is a mystery to me. They didn't come from the OS installation disc and they don't come from Office; consequently, I can't fix them. They are: Geneva CE, Geneva CY, GrCourier and N Helvitica Narrow.
Does anyone know where these fonts come from?
Maybe you are looking for
-
Hi, I´m having a problem with material stock. I get two different values on MB5B and MBEWH table for the same material, plant and date. Material: TP05891070 Company code: 531 Plant: 7101 Selection Date: 01.01.2008 to 31.01.2008 On MB5B, I get: Stock/
-
I'm 16 and I work a summer job, recently I've run out of money on the card associated with my Apple ID. I did however receive an iTunes gift card for Christmas. I redeemed the card and went to make a purchase, this is where my problem begun. Apple at
-
Field mismatched from Source system
Hi , In BI Data target,for ZZAFLD000012 field , data is not coming from CRM source system , when checking in CRM side ,it doesn't contain any data & mapped in the Standard Data source 0CRM_SRV_PROCESS_H of BI . In CRM . In CRM source sy
-
Speed has slowed to nil how do i delete all icons running in background?
speed has slowed to nil. How do I delete all icons running in background?
-
Output determination for PR, RFQ, Contracts
Hello, I want the detailed stepwise procedure for the output determination of PR, RFQ, Quotation Comparison and Contracts in SAP. I have to first check the std printout and then customize it as per clients requirement. Quick response would be very mu