-1

I have to create an Outlook e-mail using a text file as a template. I have seen some script but nothing like what I need. I also need to edit some contents of a file before creating the e-mail. I also need to know what would be the best place to put that template file.

There is a script for creating a new email but I dont know how to load test and edit from here.

Updated Code----

    --read source from the file

set theFile to "/Users/eclit/Desktop/MeetingTemplate.html"
open for access theFile
set fileContents to (read theFile)
close access theFile

tell application "Microsoft Outlook"

    set newMessage to make new outgoing message with properties {subject:"Hooray for automation", content:fileContents & return & return}
    make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
    open newMessage
end tell

Please help.

Retro
  • 3,985
  • 2
  • 17
  • 41
  • Which version of Mac OS X are you on? Would Apple Mail instead of Outlook be an option? – Mark Nov 28 '13 at 14:27
  • Your code is from [this StackOverflow post](http://stackoverflow.com/questions/9521897/create-new-outgoing-message-with-applescript-in-microsoft-outlook). I suggest that you either post [what have you tried](http://mattgemmell.com/2008/12/08/what-have-you-tried/) or hire one of the many talented developers in the [careers section](http://careers.stackoverflow.com/) – adayzdone Nov 28 '13 at 16:20
  • @adayzdone hmm is this going to be along script. I am using Mavericks and outlook 11 – Retro Nov 29 '13 at 04:57
  • Now I am able to read the file and genrate the email but i still need to replace some string with other string – Retro Nov 29 '13 at 04:59

1 Answers1

0
    --read source from the file

set theFile to "/Users/eclit/Desktop/MeetingTemplate.html"
open for access theFile
set fileContents to (read theFile)
close access theFile

on replaceText(find, replace, subject)
    set prevTIDs to text item delimiters of AppleScript
    set text item delimiters of AppleScript to find
    set subject to text items of subject

    set text item delimiters of AppleScript to replace
    set subject to "" & subject
    set text item delimiters of AppleScript to prevTIDs

    return subject
end replaceText

-- log fileContents

on categoryForName(_categoryName)
    tell application "Microsoft Outlook"
        try
            return category _categoryName
        on error
            try
                -- Getting by name doesn't always work.
                repeat with _category in categories
                    if _category's name is _categoryName then return _category
                end repeat
            end try
            make new category with properties {name:_categoryName}
        end try
        return category _categoryName
    end tell
end categoryForName

log fileContents

tell application "Microsoft Outlook"
    --set newMessage to make new outgoing message with properties {subject:"Hooray for automation", content:fileContents & return & return}
    set theCategory to my categoryForName("Work")
    --set theCategory to make new category with properties {name:"Fanciful", color:{12345, 23456, 11111}}
    set newEvent to make new calendar event with properties {subject:"Dial In : +442034333797  Conference code: 5270687926", content:fileContents}
    --make new recipient at newMessage with properties {email address:{name:"Jim Shank", address:"jim.shank@example.com"}}
    --open newMessage
    open newEvent
end tell
Retro
  • 3,985
  • 2
  • 17
  • 41