Skip to content

Instantly share code, notes, and snippets.

@cpressland
Last active April 22, 2019 23:09
Show Gist options
  • Save cpressland/65bd4fe5a769b333fd14c8ece8297054 to your computer and use it in GitHub Desktop.
Save cpressland/65bd4fe5a769b333fd14c8ece8297054 to your computer and use it in GitHub Desktop.
var outlook = Application('Microsoft Outlook')
var app = Application.currentApplication()
app.includeStandardAdditions = true
function titleCase(str) {
str = str.toLowerCase();
str = str.split(' ');
for (var i = 0; i < str.length; i++) {
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join(' ');
}
var name = app.displayDialog("What's your Name?", {
defaultAnswer: "",
withIcon: "note",
buttons: ["Cancel", "Continue"],
defaultButton: "Continue"
})
var title = app.displayDialog("What's your Job Title? (Remember to be Case Sensitive)", {
defaultAnswer: "",
withIcon: "note",
buttons: ["Cancel", "Continue"],
defaultButton: "Continue"
})
var phone = app.displayDialog("What's your Phone Number?", {
defaultAnswer: "01344 623714",
withIcon: "note",
buttons: ["Cancel", "Continue"],
defaultButton: "Continue"
})
template = `
<br />
<table width="100%" style="border-spacing: 0px">
<tr>
<td><a href="https://bink.com/"><img alt='Bink' title='Bink' src="https://bink.blob.core.windows.net/media/email/bink-logo.png"></a></td>
</tr>
<tr>
<td style="font-family: Arial, Helvetica, sans-serif; padding: 0px; font-size: 20px; font-weight: bold; white-space: nowrap;">#name#</td>
</tr>
<tr>
<td style="font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #646567; padding: 0px; padding-bottom: 5px; white-space: nowrap;">#title#</td>
</tr>
<tr>
<td style="font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #F20060; padding: 0px;">#phone#</td>
</tr>
<tr>
<td style="font-size: 14px; font-family: Arial, Helvetica, sans-serif; padding: 0px; padding-top: 5px;"><a href="https://bink.com/" style="color: #01B9FF; text-decoration: none;">bink.com</a></td>
</tr>
<tr>
<td width="100%" colspan="2" style="font-size: 14px; font-family: Arial, Helvetica, sans-serif; padding: 0px; padding-top: 5px;">
<p style="color: #F20060;">
<a href="https://www.linkedin.com/company/bink" style="text-decoration:none; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #01B9FF;">LinkedIn</a>&nbsp;&nbsp;|&nbsp;
<a href="https://www.facebook.com/hellobink" style="text-decoration:none; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #01B9FF;">Facebook</a>&nbsp;&nbsp;|&nbsp;
<a href="https://twitter.com/HelloBink" style="text-decoration:none; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #01B9FF;">Twitter</a>&nbsp;&nbsp;|&nbsp;
<a href="https://www.instagram.com/binkhq/" style="text-decoration:none; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #01B9FF;">Instagram</a>
</p>
</td>
</tr>
</table>
`
var html = template.replace("#name#", titleCase(name.textReturned))
.replace("#title#", title.textReturned)
.replace("#phone#", phone.textReturned)
sig = outlook.Signature({
name: "Bink - " + titleCase(name.textReturned),
content: html
})
sig.make()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment