PC Review


Reply
Thread Tools Rate Thread

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

 
 
New Member
Join Date: Nov 2011
Location: North of Detroit, MI
Posts: 2
 
      4th Dec 2011
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Subject Line". How can I make the e-mail Subject Line 'uneditabl Vince Innovation Microsoft Outlook Discussion 2 17th Apr 2010 09:25 PM
create append query resulting in multiple new records 8l2255 Microsoft Access Queries 4 26th Nov 2009 06:04 AM
queries resulting resulting is a drop-down =?Utf-8?B?SmVlbQ==?= Microsoft Access Queries 1 30th Jul 2007 09:51 PM
Automatically modifying the subject line =?Utf-8?B?bmF0aGFuX3NoaWg=?= Microsoft Outlook Discussion 1 28th Aug 2006 09:05 PM
Append Query resulting in duplicate records =?Utf-8?B?Um9k?= Microsoft Access Queries 4 11th Aug 2006 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 AM.