Thanks Michael. Figured it out and it has been working with no glitches. Now I have another problem. I share my task folder with other co-workers. They use this macro to reply to my emails that are shared on the task folder. Work will not allow me to delegate access to them so they can send on my behalf, so can I add something to the macro to change the From: field to them instead of from me? Here is the current macro I have.
Sub Reply()
Dim objItem As Object
Dim intLocAddress As Integer
Dim intLocCRLF As Integer
Dim strAddress As String
Dim objReply As MailItem
'this gets the subject from original email
Set objItem = GetCurrentItem()
If objItem.Class = olMail Then
' find the requestor address
strAddress = ParseTextLinePair(objItem.Body, "Email: ")
'strAddress = email in original body of Dig Alert
' create the reply, add the address and display
'Set objReply puts RE: xxxxx into subject field objItem.Reply
Set objReply = objItem.Reply
'puts email address from orig. email into new email To: field
objReply.To = strAddress
'removes the Re: in the subject
objReply.subject = "USA Dig Alert"
objReply.subject = Replace(objReply.subject, "Re:", "", , , vbTextCompare)
objReply.Body = "NO CONFLICT WITH SEWER MAINTENANCE FORCE MAIN." & vbNewLine & vbNewLine & vbNewLine & objItem.Body
objReply.Display
End If
Set objReply = Nothing
Set objItem = Nothing
End Sub
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.CurrentItem 'Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
' anything else will result in an error, which is
' why we have the error handler above
End Select
Set objApp = Nothing
End Function
Function ParseTextLinePair(strSource As String, strLabel As String)
Dim intLocLabel As Integer
Dim intLocCRLF As Integer
Dim intLenLabel As Integer
Dim strText As String
' locate the label in the source text
intLocLabel = InStr(strSource, strLabel) 'strLabel adds email in body to To: Field
intLenLabel = Len(strLabel)
If intLocLabel > 0 Then
intLocCRLF = InStr(intLocLabel, strSource, vbCrLf)
If intLocCRLF > 0 Then
intLocLabel = intLocLabel + intLenLabel
strText = Mid(strSource, _
intLocLabel, _
intLocCRLF - intLocLabel)
Else
intLocLabel = Mid(strSource, intLocLabel + intLenLabel)
End If
End If
ParseTextLinePair = Trim(strText)
End Function