I have a piece of applescript that creates a new mail message and then loads a template into that message.
So far so good.
I want to get the content ( body text ) after the template being loaded.
How can I get the body content after loading the template?
Reason is, I need to replace some text ("/date/") with a date.
The body could be HTML or just plain text.
I know how to get the content when an existing mail is selected, so it is questioned really only about this case.
BTW, a secondary question. Now I use button click to load the template, but is there a better way, for example load the template directly by name?
Thank you very much
edit addition
I'am a step further. It is solved for this problem.
First I did make a new email using
tell application mail
-- make email and visible
-- then for using the keystrokes and gui to get the template
tell application system events
tell process mail
-- tell window to get template - works fine
-- SEE NOTE 1
set _content to content of myMessage -- it doesn't work, message ID is there
set the _content to (get the value of the last scroll area) -- it doesn't work
-- IN HERE I CANT'T get the content of the message, should be with the ui?
-- if someone knows, please
end tell
end tell
-- now I have to Activate the mail app. I didn't know
activate --
set _content to content of myMessage -- works
set the clipboard to _content as string -- works almost
-- SEE NOTE2
Note 1
In here I can't get the content of the message, should be with the ui?
if someone knows, please
Note 2
If I paste the clipboard, the text has a different font.
How can I get the right type of font in my clipboard?
Still searching for a better way for getting the template.
I answered a similar question here
https://stackoverflow.com/a/23069553/348694
The trick there was to use a preformatted rtf file, copy it to the clipboard and then paste it in the message.
This way you can easily change the content with a search/replace before you copy it into the clipboard for pasting.
HTH
Related
I need to select some text from a web page and then copy it using Ctrl-C. I know I can use send keys for Ctrl-C but how do I select the text from web page? The requirement is that I don't just check the roproperty I need to select(highlight) the text on the web page.
The usual way to get text from a web page using UFT is not via CtrC but via UFT's built in methods.
Select a test object and use it's GetROProperty "innertext" function
Use an text (or text area) output value
As for clipboard, do you really need to put the text in the clipboard? Usually variables and output parameters are the way you want to go.
If you do want to interact with the system's clipboard you can use Mercury.Clipboard supplied by UFT
Set cb = CreateObject("Mercury.Clipboard")
cb.SetText "This is easier than Ctrl-C"
I'm new to AppleScript but learned a bit from searching online. Basically I would like to forward iMessage messages to an e-mail address. I did this with the following script:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"thesubject", content:theMessage, visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties {address:"myemail#gmail.com"}
send
end tell
end tell
end message received
end using terms from
Works great and it puts the iMessage in the content of an e-mail that gets sent to me.
Now I'm trying to do this with attachments as well. I modified the code to give me 4 beeps when a file is received but nothing happens. Posted this question to Apple's website but then I thought I would have better luck here. Any help would really be appreciated I've searched google for hours and I'm kind of at a dead end.
Modified Code:
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
tell application "Mail"
set theNewMessage to make new outgoing message with properties
{subject:"thesubject", content:theMessage, visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties
{address:"myemail#gmail.com"}
send
end tell
end tell
end message received
on completed file transfer theFile
beep 4
end completed file transfer
end using terms from
So with a bit more looking I learned that Messages is very similar to iChat which I found some example code on Apple's Developer site:
https://developer.apple.com/library/mac/#samplecode/iChatAppleScriptSamples/Listings/Add_Incoming_Images_to_iPhoto_Add_incoming_image_to_iPhoto_applescript.html
So I changed my code to this:
on received file transfer invitation theFileTransfer
accept transfer of theFileTransfer
tell application "Mail"
set theNewMessage to make new outgoing message with properties
{subject:"photo", content:"themessage", visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties
{address:"myemail#gmail.com"}
send
end tell
end tell
end received file transfer invitation
I also made sure to have the script run when incoming file in the Messages preferences window, but still not getting any response. Very frustrating, I'm thinking that a picture might not be a file transfer but rather an inline text attachment of sorts.
Looking at the Messages dictionary I found:
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
But I have no idea how to use classes in AppleScript.
Again any help would be greatly appreciated!
I’ve been in AppleScript hell for the past few days. Apparently, when Apple changed how Messages.app deals with events (one event handler instead of a script per event), they either broke or failed to implement file transfer-related stuff.
Attachments are not accessible because you are never given a file object; rather (you’ve discovered) you get a message string and user and chat objects.
There’s good news in all of this, though (kind of). on message received is triggered for text messages and media messages. For media messages, the text string your handler gets is empty. You can hit up last file transfer to see if anything was recently received and act accordingly.
Here’s the nasty hack I’m using in the message received handler to get attachments:
set fileName to ""
if direction of last file transfer is incoming then
-- compare diff in seconds
if (current date) - (started of last file transfer) < 5 then
set f to file of the last file transfer
set fileName to POSIX path of f
end if
end if
Do note that it’s only the start of an idea. I haven’t had time to improve it since I banged it out a few days ago. You’ll get the full path to the file in fileName if the message has media.
For the Mail.app side of things, basically, I have no clue. To send images with Messages.app, I’m using set theMessage to POSIX file fileName. Probably something along those lines for setting the file for attachment.
AppleScript is like messed up English, which is why you can use first and last and 2nd and even 1th or 3nd. You can do stuff like get number of file transfers but get number of file transfer is also valid.
Partially related: checkout out properties if you ever want to inspect an object. properties plus the AppleScript Editor (as in get properties of first chat) are a lifesaver.
Good luck.
I can't find the solution for my problem. So, in my send-mailmessage html body is field that should be redirected to file which is included as attachment in message. How can I create hyperlink to that file in mail, when client opens it?
I don't know if you get my idea. In other words, in message I have attached file, and then there is field which should be a hyperlink to attached file. When client receives message he/she should press the link and then attached file opens.
I searched almost everything in everwhere but can't find a appropriate solution how to solve this.
This isn't really a PowerShell question, since this issue has nothing to do with the functionality of the Send-MailMessage cmdlet.
In any case, the reason you can't find a solution anywhere is that what you're trying to do is impossible. There is no way that a hyperlink in an e-mail message can point to a file attached to that message. Different mail clients on different operating systems store attachments in different locations. Even if you want to assume that all your recipients are running Outlook on Windows, there are different versions of both. Even if you know for a fact that all recipients are running a specific version of Outlook on a specific version of Windows, you're still out of luck. Outlook stores attachments in a subfolder in the Temporary Internet Files in the user's profile that has a randomly generated name. There's no way to inject code into a hyperlink in an email message, so without knowing the exact local file location, you can't link to it.
I suppose if you're really determined you could have the hyperlink point to a web page that runs some complex javascript code that tries to figure out where the attachment is stored, but that's a major undertaking, and would break if the recipient's default browser has javascript disabled.
Which begs the question, why exactly are you trying to do this? So that recipients can click once instead of having to double-click to open the attachment?
I have found that you can make a hyperlink point to a file share that you know the recipients have access to.
To do so:
Simply make each hyperlink point to the specific file and there you have it.
They have to have permissions to access that file share, or there is a much better way now that I haven't thought of.
Oh well, this works for me, for now.
I want to create a web template form for a helpdesk. Basically users will have multiple textboxes to fill out and at the bottom would be a "Copy to Clipboard" button which would copy everything in a format they can paste into the ticket system.
For example a text box might be "Phone Number: ____", when pasting the clipboard contents it would paste as "Phone Number: ".
It's been a long time since I've done web development, from what I understand I'll need to save the textboxes as variables and use javascript, which is alien to me, would appreciate anything that would get me pointed in the right direction.
Thanks
write code to gather that data together and save to a file, display in a messagebox, etc.., Once you have that, THEN worry about copying to the clipboard. You're just confusing things and limiting your scope by calling this a clipboard question.
I think this might be a simple question but I cannot seem to figure it out.
I have a workflow which simply sends a mail. In the content of the mail I
have a hyperlink going back to our SAP CRM system. I pass some parameters to this hyperlink.
The workflow works fine and the email is sent, however, the hyperlink goes onto the second line of the mail and becomes in active. If I copy the entire hyperlink and paste it in a browser it works.
The issue is I don't want users to copy and paste, I simply want them to click on the hyperlink.
Here is a screen print of what I am talking about
http://img402.imageshack.us/img402/9471/38348167.png
And here is a screen print of the actual email that is sent:
http://img210.imageshack.us/img210/6424/14370746.png
I tried going into transaction PFTC (Task Maintain) I entered my task and opened it up. I went to the tab description
and hit the edit button and I changed the tag column to continuous text but that didnt work, and then I tried extended line
and that too didn't make a difference.
Here is a screen shot of that:
http://img341.imageshack.us/img341/6254/37776438.png
My question is, is there any way to get the hyperlink on one line or even to have it be clickable on 2 lines?
Thanks so much.
From what I can see, that's a limitation of SAPconnect when sending plain-text emails. You could reconfigure the system to send HTML mails, but this would affect EVERY outgoing mail and should be handled extremely cautious. I'd suggest you write a small class to assemble and send the HTML mail and call it from the step. I'd use the BCS for sending the mail - it has an excellent online documentation and comes with several demo programs (BCS_EXAMPLE_*). You could assemble the HTML body using ABAP, although this usually yields rather messy code. Cleaner ways of ding this would be to either put all of the input data into a structure and use a simple transformation or dynamic documents (see for example report DD_ADD_LINK).