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

Discussion in 'Microsoft Outlook Form Programming' started by khkeener, Dec 4, 2011.

  1. khkeener

    khkeener

    Joined:
    Nov 28, 2011
    Messages:
    2
    Likes Received:
    0
    Location:
    North of Detroit, MI
    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
     
    khkeener, Dec 4, 2011
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cvegas

    Insert Date From Form Into Subject Line

    cvegas, Oct 2, 2003, in forum: Microsoft Outlook Form Programming
    Replies:
    1
    Views:
    772
    Sue Mosher [MVP]
    Oct 3, 2003
  2. CJM

    Simple form code - updating task subject & notes from form values

    CJM, Nov 23, 2004, in forum: Microsoft Outlook Form Programming
    Replies:
    0
    Views:
    248
  3. Guest

    Populate Subject line with form values

    Guest, Nov 3, 2006, in forum: Microsoft Outlook Form Programming
    Replies:
    3
    Views:
    302
    Guest
    Nov 3, 2006
  4. russeller

    New emails to have particular word at start of the Subject line/he

    russeller, Jan 23, 2009, in forum: Microsoft Outlook Form Programming
    Replies:
    2
    Views:
    254
    Bryce
    Feb 6, 2009
  5. Shimon
    Replies:
    0
    Views:
    374
    Shimon
    May 27, 2009
Loading...

Share This Page