I have got three other scripts to work just having some problems with this one. I am trying to create an email from a task and taking some of the details from the task. I would also like to create hyperlink within the email for the receiving person to be able to open the task. We share the same tasks. This is what I have so far which works and creates the email with the hyperlink which also works but it throws an run time error of 438 this Object does not support this property or method. It highlights the Hyperlink row as being the problem.
In addition to this can anyone help with getting the newly created email as being the active object other than displaying it.
This is the code I have so far. Any help would be very much appreciated.
Sub TaskEmailUpdate()
Dim objOL As Outlook.Application
Dim objTask As TaskItem
Dim objMail As MailItem
Dim objNS As Outlook.NameSpace
Dim objDoc As Word.Document
Dim objSel As Word.Selection
Dim strStatus, strHyperLink, strText, strRow As String
Set objOL = Application
Set objTask = objOL.ActiveExplorer.Selection.Item(1)
If objTask.Class <> olTask Then
MsgBox "You have to have a task selected to run this macro"
Exit Sub
End If
If objTask.Complete = "True" Then
strStatus = "Task Completed on - " & objTask.DateCompleted
Else
strStatus = "Task Status Update - " & Date
End If
strHyperLink = "Outlook:" & objTask.EntryID
Set objMail = Application.CreateItem(olMailItem)
objMail.Display
Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objNS = objOL.Session
Set objSel = objDoc.Windows(1).Selection
objSel.Collapse wdCollapseStart
objSel.Move wdStory, -1
objSel.InsertBefore objDoc.Hyperlinks.Add(objSel.Range, strHyperLink, "", "", "Direct Link to Task", "")
With objMail
.To = "*****@****.com"
.Subject = strStatus & " - " & objTask.Subject
End With
Set objMail = Nothing
Set objTask = Nothing
Set objOL = Nothing
Set objDoc = Nothing
Set objNS = Nothing
Set objSel = Nothing
End Sub