Basic(ish) Applescript! Please Help!

Discussion in 'macOS' started by stustu242, Jun 12, 2011.

  1. stustu242 macrumors newbie

    Jun 7, 2011
    Hi. This is my second post on mac rumors and I would like to see a reply to this post. Anyway so I was making a script which opens a typing dialog which will send what you typed in the box to your email address... This is how I have done so far...

    display dialog "Type your message" with icon 2 with title "Message Sender" default answer "" buttons {"Don't Send", "Send"} default button 2
    copy the result as list to {text_returned, button_pressed}

    Ok, now I need to get the reply from the original dialog box to be the "content" of the sent message through outlook.

    tell application "Microsoft Outlook"
    set newMessage to make new outgoing message with properties {subject:"Blah", content:""}
    make new recipient at newMessage with properties {email address:{name:"Mac User", address:""}}
    send newMessage
    end tell

    Ok if you could re-write this script so It works, then I would be so so happy!:D

    P.S. My last post got no replies so replies would make me grateful!:D
  2. itsmrjon macrumors regular

    Jun 11, 2011
    I dont have outlook, so i cant give you an outlook specific working applescript...

    but heres one using mail

    display dialog "Type" default answer "Meow" buttons {"Send", "Cancel"} default button 1
    copy the result as list to {text_returned, button_pressed}
    if button_pressed is "Send" then
    	tell application "Mail"
    		set newMessage to make new outgoing message with properties {visible:true, subject:"blah", content:text_returned}
    		tell newMessage
    			make new recipient at end of to recipients with properties {name:"person", address:""}
    		end tell
    		send newMessage
    	end tell
    end if
    I'd assume its very similar for outlook

    this post should also probably be in the programming subforum, you'd probably get faster/more responses for this type of question there
  3. stustu242 thread starter macrumors newbie

    Jun 7, 2011
    thanks so much!!! Its working now!! I really appreciate that!!!
  4. zzz1822 macrumors newbie

    Mar 26, 2012
    Getting Microsoft Outlook to send an outgoing email

    I couldn't get itsmrjon's script to work for me but a little modification did send. Here it is incase another person is having problems.

    Specs are: MacOS 10.7.3, Microsoft Outlook for Mac 14.0.0 connected to an Exchange server.

    Code is:
    tell application "Microsoft Outlook"
    set OutgoingEmail to make new outgoing message with properties {subject:"subject", content:"body"}
    make new recipient at OutgoingEmail with properties {email address:{name:"", address:""}}
    send message id (id of OutgoingEmail)
    end tell

    Note: Sometimes the email sends but it also stays in Drafts. It seemed to only happen during testing. Haven't used this enough to know if it happens during production.

    Rob Stokes

Share This Page