New Outlook Task → Insert Hyperlink [COM]

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jarhead
Posts: 151
Joined: 09 Sep 2020, 12:43

New Outlook Task → Insert Hyperlink [COM]

Post by jarhead » 17 May 2022, 12:03

I have a script that pulls data, formats it, saves it and then adds a new task in Outlook with a one hour reminder.

The body of the task contains a hyperlink but it displays as <a href="https://website.com/stuff/edit.aspx?ID=164265">1234</a> versus just 1234 which is hyperlinked. I've read the COM docs and noticed tasks use RTFBody (I could not find an HTML option) but the link itself (https://website.com/stuff/edit.aspx?ID=164265) is hyperlinked in the task body (see screenshot) so clearly that is not necessary. In an Outlook email, use of a href works. Any ideas? Thanks!

Code: Select all

linktest := "https://website.com/stuff/edit.aspx?ID="

FormatTime, DateSub,, ShortDate
FormatTime, TimeSub,, Time
olApp := ComObjCreate("Outlook.Application")
olTask := olApp.CreateItem(3)
olTask.StartDate := DateSub
olTask.DueDate := DateSub
olTask.Subject := "Report F/U - Smith (1234)"
olTask.Body := "Check status of report regarding Smith (1234) submitted on " . DateSub . " at " . TimeSub . "`n`n <a href=""" . linktest . LinkNum . """>" . WebNum . "</a>"
olTask.ReminderSet := true
olTask.Status := 1
olTask.ReminderTime := AddTime(60)
olTask.Display

image.png
image.png (37.41 KiB) Viewed 306 times

jarhead
Posts: 151
Joined: 09 Sep 2020, 12:43

Re: New Outlook Task → Insert Hyperlink [COM]

Post by jarhead » 17 May 2022, 14:29

I think I'm getting close. I found the following VBA script but not sure how to change it for use in AHK:

Code: Select all

strLink = "https://google.com
strLinkText = "Google"
Set objInsp = NewTask.GetInspector
Set objDoc = objInsp.WordEditor
Set objSel - objDoc.Windows(1).Selection
objDoc.Hyperlinks.Add objSel.Range, strLink, _
"", "", strLinkText, ""
Pretty sure I'm close but not sure how to change the last section regarding Hyperlinks:

Code: Select all

olApp := ComObjCreate("Outlook.Application")
olTask := olApp.CreateItem(3)
myInspect := olTask.GetInspector
myTask = myInspect.WordEditor
mySel := myTask.Windows(1).Selection

; myTask.Hyperlinks.Add mySel.Range, strLink, _ 
; "", "", strLinkText, ""

Post Reply

Return to “Ask for Help (v1)”