Skip to content

Instantly share code, notes, and snippets.

@tdalon
Created October 16, 2023 07:15
Show Gist options
  • Save tdalon/ecc4d748af11d92326b5146bd3ff36ad to your computer and use it in GitHub Desktop.
Save tdalon/ecc4d748af11d92326b5146bd3ff36ad to your computer and use it in GitHub Desktop.
Quick Share Url by Email with AutoHotkey
; IntelliSharebyEmailActiveURL Ctrl+Shift+M
#If Browser_WinActive()
^+m:: ; <--- [Browser] Share by eMail active url
EmailShareActiveUrl:
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
Run, "https://tdalon.blogspot.com/2023/10/share-url-by-email.html"
return
}
sLink := Browser_GetUrl()
If ErrorLevel {
MsgBox 0x1010, Error, No url could be copied!
return
}
AppList = Jira,Confluence,Connections
Loop, Parse, AppList, `,
{
If FileExist("Lib/" . A_LoopField . ".ahk") {
FunStr := A_LoopField . "_IsUrl"
If %FunStr%(sLink) {
FunStr := A_LoopField . "_CleanLink"
link := %FunStr%(sUrl)
sLink := link[1]
linktext := link[2]
Goto, WriteEmail
}
}
}
sLink := IntelliPaste_CleanUrl(sLink)
WinGetActiveTitle, linktext
; Remove trailing - containing program e.g. - Google Chrome
StringGetPos,pos,linktext,%A_space%-,R
if (pos != -1)
linktext := SubStr(linktext,1,pos)
WriteEmail:
sHTMLBody = Hello<br>I thought you might be interested in this post: <a href="%sLink%">%linktext%</a>.<br>
; Create Email using ComObj
Try
MailItem := ComObjActive("Outlook.Application").CreateItem(0)
Catch
MailItem := ComObjCreate("Outlook.Application").CreateItem(0)
;MailItem.BodyFormat := 2 ; olFormatHTML
MailItem.Subject := linktext
MailItem.HTMLBody := sHTMLBody
MailItem.Display ;Make email visible
return
@tdalon
Copy link
Author

tdalon commented Oct 16, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment