Purpose
Generate an Outlook email

1. Send as plain text
2. Send as HTML with embedded image

Solution
Use a JavaScript routine that calls up Outlook

Important hint for the "new outlook"
The "New Outlook for Windows" does not support COM add-ins, as it shares a codebase with Outlook on the web, focusing on web add-ins instead: The method described here cannot be used anymore then.

Example
In a particular transaction we want to generate an email with predefined addressee, cc, subject, email text and attachment list.

For our example we use:

adressee: name@company.com
cc: xyz@abc.com
subject: Project documentation version 15
email text:
Please find attached our new project documentation.

Regards
Mike. B. Smith

attachment: C:\temp\project1208.pdf

You can send the email immediately via Outlook or open up an Outlook window and let the user send the generated email:

 

InputScript

GuiXT
// build email body
// for this example we use a few fixed text lines
// for longer texts you may use a template text file and
// CopyText ... fromTemplate=... whch replaces variables in the text
Clear text[emailbody]
Set V[line] "Please find attached our new project documentation."
CopyText fromString="line" toText="emailbody" -appendLine
Set V[line] ""
CopyText fromString="line" toText="emailbody" -appendLine
Set V[line] "Regards"
CopyText fromString="line" toText="emailbody" -appendLine
Set V[line] "Mike. B. Smith"
CopyText fromString="line" toText="emailbody" -appendLine

// attachments
Set text[emailattachments] "C:\temp\project1208.pdf"

// call up outlook via a JavaScript function
CallJS OutlookEmail _
   "name@company.com" _
   "Project documentation version 15" _
   "xyz@abc.com" _
    emailbody _
    emailattachments

// return
return



JavaScript

JavaScript
Send embedded HTML and images


The text in an email is sent as plain text in most cases. However, it is also possible to use HTML code, e.g. to style the text or to embed images directly. This is possible with the following coding:

Inputscript:

GuiXT
// Send E-Mail with HTML body and embedded image

clear text[emailbody] 

Set V[line] "

Construction Plan A

" CopyText fromString="line" toText="emailbody" -appendLine Set V[line] "" CopyText fromString="line" toText="emailbody" -appendLine Set V[line] "" CopyText fromString="line" toText="emailbody" -appendLine Set V[line] "
Best Regards,
FredSumit" CopyText fromString="line" toText="emailbody" -appendLine // attachments Set text[emailattachments] "C:\temp\architecture.jpg"  // call up outlook via a JavaScript function CallJS OutlookEmail _    "name@company.com" _    "Project documentation version 15" _    "xyz@abc.com" _     emailbody _     emailattachments return


JavaScript
JavaScript

Components
InputAssistant + Controls