Modifying a Form to append the resulting email's subject line

Joined
Nov 28, 2011
Messages
2
Reaction score
0
I had originally posted this in the Microsoft Outlook VBA Programming, and have since realized that it should have probably been posted here instead.

I created a Form in MS Outlook that allows the user to request time off (leave). They fill in the required information (employee ID number, name, dates to be taken, address, etc.) and then send it to their supervisor. If their supervisor has authority to grant the leave then the form is approved and a copy is sent to the personnel office.

If the supervisor is required to send the request to a higher level supervisor, then it is forwarded using either an "Approved and Forwarded" action or "Rejected and Forwarded" action.

The subject line of this email is populated with the words and data, "Leave Request", employee's name, the date the leave begins and the date the leave ends

When the request is forwarded to the higher level supervisor, I would like for the subject line to be appended with wording to the effect of, "Approved and Forwarded" or "Rejected and Forwarded", along with the information already there.

I found an example that uses a Select Case statement and modified it to what I thought would meet my needs but it will not add the required verbage.

This is the code that I found
Code:
Function Item_CustomAction(ByVal Action, ByVal NewItem)
Select Case Action.Name
        Case "Approve and forward to next in chain of command"
            MsgBox "Please Send To Your Supervisor"
            Item.Body = My10Value
 End Select

End Function
This is the entire code that I am using
Code:
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem) 

Function Item_Send()
    MyValue = Item.UserProperties("Have Replies Sent To")
    My2Value = Item.UserProperties("Name")
    My3Value = Item.UserProperties("frmBeginLeave")
    My4Value = Item.UserProperties("frmEndLeave")
    My5Value = Item.UserProperties("Date")
    My6Value = Item.UserProperties("EmployeeID")
    My7Value = Item.UserProperties("LeaveAddress")
    My8Value = Item.UserProperties("Request")
    My9Value = Item.UserProperties("RequestNotes")
    My12Value = Item.UserProperties("LeaveToBeCharged")
    SubjValue = Item.UserProperties("Subject")
    date1 = Instr(4,My3Value,"/")
    datea1 = Mid(My3Value,1,date1+4)
    date2 = Instr(4,My4Value,"/")
    dateb2 = Mid(My4Value,1,date2+4)
    My10Value  = "Requestor: " & MyValue & VbLf & "Employee ID: " &  My6Value & VbLf & "Begin Date: " & datea1 & VbLf &  "End Date: " & dateb2 & VbLf & "Leave To Be Charged: " &  My12Value & VbLf & "Leave Address: " & My7Value & VbLf  & VbLf & My9Value & VbLf & "*** *** *** *** ***" &  VbLf & VbLf
    My11Value = MyValue
    Item.UserProperties("Request").Value = My10Value
    Item.UserProperties("Have Replies Sent To").Value = My11Value
    Item.Body = My10Value
End Function

Function Item_CustomAction(ByVal Action, ByVal NewItem)
Select Case Action.Name
        Case "Approve and forward to next in chain of command"
            Item.Subject = "Approved and forwarded: " & SubjValue
 End Select
End Function
I also tried substituting the Select Case section with this but no luck either
Code:
Function Item_Forward(ByVal ForwardItem)
    Select Case Action.Name
        Case "Approve and forward to next in chain of command"
        Item.Subject = "Approved and forwarded: " & SubjValue
    End Select
End Function
I've run out of ideas on what to try. I've used Google many times, and have found several other suggestions close to what I've already tried and nothing seems to work.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top